Skip to content

Commit 4a6b450

Browse files
authored
Merge pull request #2339 from nagilson/nagilson-script-path-issue
Fix Bundling of Install Scripts
2 parents 1f2ad79 + cf8ba10 commit 4a6b450

File tree

18 files changed

+201
-156
lines changed

18 files changed

+201
-156
lines changed

Documentation/contributing-workflow.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ We use and recommend the following workflow:
2222
- Please follow our [Commit Messages](contributing.md#commit-messages) guidance.
2323
5. Add new tests corresponding to your change, if applicable.
2424

25-
If you are having difficulty debugging changes to the library, you may want to incorporate the logging messages into your test session. To do so, set the debugOn flag to true [Here](../vscode-dotnet-runtime-library/src/Utils/Debugging.ts).
2625
Note that the runtime and sdk extensions can be tested (with breakpoints as well, through the .js files) using their corresponding workspace and launch profiles by opening their root folders in vscode.
2726
For the library, those tests are reachable by going through the runtime extension workspace and adding the runtime-library folder to the workspace. But logging may be a better approach to debug this code.
2827

build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ $successColor = "Green"
44

55
#################### Download backup install scripts ####################
66
function DownloadInstallScripts() {
7-
Invoke-WebRequest https://dot.net/v1/dotnet-install.ps1 -OutFile "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
8-
Invoke-WebRequest https://dot.net/v1/dotnet-install.sh -OutFile "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
7+
Invoke-WebRequest https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.ps1 -OutFile "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
8+
Invoke-WebRequest https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh -OutFile "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
99
}
1010

1111
try

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ NC=`tput sgr0`
66
echo ""
77
echo "----------- Bundling Install Scripts -----------"
88
echo ""
9-
curl https://dot.net/v1/dotnet-install.ps1 --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
10-
curl https://dot.net/v1/dotnet-install.sh --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
9+
curl https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.ps1 --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
10+
curl https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
1111
if [ $? -eq 0 ];
1212
then
1313
echo ""

mock-webpack.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# The library doesn't get webpacked, but it needs the copy of items that would normally be webpacked
22
# ... into the SDK or Runtime Extension for it to run in local dev scenarios.
33
Copy-Item ".\vscode-dotnet-runtime-library\distro-data\" -Destination ".\vscode-dotnet-runtime-library\dist\Acquisition\" -Recurse -Force
4-
Copy-Item ".\vscode-dotnet-runtime-library\install scripts\" -Destination ".\vscode-dotnet-runtime-library\dist\utils\" -Recurse -Force
4+
Copy-Item ".\vscode-dotnet-runtime-library\install scripts\" -Destination ".\vscode-dotnet-runtime-library\dist\" -Recurse -Force

mock-webpack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ echo ""
22
echo "----------- Copying Library Webpacked Dependencies -----------"
33
echo "" # See the build.ps1 for more details on why we do this
44
cp -r ./vscode-dotnet-runtime-library/distro-data ./vscode-dotnet-runtime-library/dist/Acquisition
5-
cp -r "./vscode-dotnet-runtime-library/install scripts" ./vscode-dotnet-runtime-library/dist/Utils
5+
cp -r "./vscode-dotnet-runtime-library/install scripts" ./vscode-dotnet-runtime-library/dist

vscode-dotnet-runtime-library/src/Acquisition/DotnetCoreAcquisitionWorker.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { IDotnetAcquireResult } from '../IDotnetAcquireResult';
4747
import { IExtensionState } from '../IExtensionState';
4848
import { IVSCodeExtensionContext } from '../IVSCodeExtensionContext';
4949
import { CommandExecutor } from '../Utils/CommandExecutor';
50-
import { Debugging } from '../Utils/Debugging';
5150
import { FileUtilities } from '../Utils/FileUtilities';
5251
import { IFileUtilities } from '../Utils/IFileUtilities';
5352
import { getInstallFromContext, getInstallIdCustomArchitecture } from '../Utils/InstallIdUtilities';
@@ -246,8 +245,6 @@ To keep your .NET version up to date, please reconnect to the internet at your s
246245
let acquisitionPromise = null;
247246
if (globalInstallerResolver)
248247
{
249-
Debugging.log(`The Acquisition Worker has Determined a Global Install was requested.`, context.eventStream);
250-
251248
acquisitionPromise = this.acquireGlobalCore(context, globalInstallerResolver, install).catch(async (error: any) =>
252249
{
253250
await new CommandExecutor(context, this.utilityContext).endSudoProcessMaster(context.eventStream).catch(() => {});

vscode-dotnet-runtime-library/src/Acquisition/InstallScriptAcquisitionWorker.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import
1111
DotnetInstallScriptAcquisitionError,
1212
EventBasedError,
1313
} from '../EventStream/EventStreamEvents';
14-
import { Debugging } from '../Utils/Debugging';
1514
import { FileUtilities } from '../Utils/FileUtilities';
1615
import { getInstallFromContext } from '../Utils/InstallIdUtilities';
1716
import { WebRequestWorkerSingleton } from '../Utils/WebRequestWorkerSingleton';
@@ -27,26 +26,35 @@ export class InstallScriptAcquisitionWorker implements IInstallScriptAcquisition
2726
private readonly fileUtilities: FileUtilities;
2827
private readonly scriptFileEnding = os.platform() === 'win32' ? 'ps1' : 'sh';
2928

30-
29+
protected readonly scriptFileName: string = 'dotnet-install';
3130

3231
constructor(private readonly context: IAcquisitionWorkerContext)
3332
{
34-
const scriptFileName = 'dotnet-install';
35-
this.scriptFilePath = path.join(__dirname, 'install scripts', `${scriptFileName}.${this.scriptFileEnding}`);
33+
this.scriptFilePath = path.join(__dirname, 'install scripts', `${this.scriptFileName}.${this.scriptFileEnding}`);
3634
this.webWorker = WebRequestWorkerSingleton.getInstance();
3735
this.fileUtilities = new FileUtilities();
3836
}
3937

38+
private async getFallbackScript(): Promise<string>
39+
{
40+
const fallbackPath = this.getFallbackScriptPath();
41+
if ((await this.fileUtilities.exists(fallbackPath)))
42+
{
43+
this.context.eventStream.post(new DotnetFallbackInstallScriptUsed());
44+
return fallbackPath;
45+
}
46+
47+
throw new EventBasedError('UnableToAcquireDotnetInstallScript', `Failed to Find Dotnet Install Script: ${this.scriptFileName}.${this.scriptFileEnding}. Please download .NET Manually.`);
48+
}
49+
4050
public async getDotnetInstallScriptPath(): Promise<string>
4151
{
4252
try
4353
{
44-
Debugging.log('getDotnetInstallScriptPath() invoked.');
4554
const script = await this.webWorker.getCachedData(`${this.scriptAcquisitionUrl}${this.scriptFileEnding}`, this.context);
4655
if (!script)
4756
{
48-
Debugging.log('The request to acquire the script failed.');
49-
throw new EventBasedError('NoInstallScriptPathExists', 'Unable to get script path.');
57+
return this.getFallbackScript();
5058
}
5159

5260
await this.fileUtilities.writeFileOntoDisk(script, this.scriptFilePath, this.context.eventStream);
@@ -55,19 +63,8 @@ export class InstallScriptAcquisitionWorker implements IInstallScriptAcquisition
5563
}
5664
catch (error: any)
5765
{
58-
Debugging.log('An error occurred processing the install script.');
5966
this.context.eventStream.post(new DotnetInstallScriptAcquisitionError(error as Error, getInstallFromContext(this.context)));
60-
61-
// Try to use fallback install script
62-
const fallbackPath = this.getFallbackScriptPath();
63-
if ((await this.fileUtilities.exists(fallbackPath)))
64-
{
65-
Debugging.log('Returning the fallback script path.');
66-
this.context.eventStream.post(new DotnetFallbackInstallScriptUsed());
67-
return fallbackPath;
68-
}
69-
70-
throw new EventBasedError('UnableToAcquireDotnetInstallScript', `Failed to Acquire Dotnet Install Script: ${error}`);
67+
return this.getFallbackScript();
7168
}
7269
}
7370

vscode-dotnet-runtime-library/src/Acquisition/VersionResolver.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import
1313
EventBasedError,
1414
EventCancellationError
1515
} from '../EventStream/EventStreamEvents';
16-
import { Debugging } from '../Utils/Debugging';
1716
import { getAssumedInstallInfo, getInstallFromContext } from '../Utils/InstallIdUtilities';
1817
import { WebRequestWorkerSingleton } from '../Utils/WebRequestWorkerSingleton';
1918

@@ -169,18 +168,15 @@ export class VersionResolver implements IVersionResolver
169168
{
170169
parsedVer = null;
171170
}
172-
Debugging.log(`Semver parsing passed: ${version}.`, this.context.eventStream);
173171

174172
if (!parsedVer || (version.split('.').length !== 2 && version.split('.').length !== 3))
175173
{
176-
Debugging.log(`Resolving the version: ${version} ... it is invalid!`, this.context.eventStream);
177174
const err = new DotnetVersionResolutionError(new EventCancellationError('DotnetVersionResolutionError',
178175
`An invalid version was requested. Version: ${version}`),
179176
getAssumedInstallInfo(version, this.context.acquisitionContext.mode!));
180177
this.context.eventStream.post(err);
181178
throw err.error;
182179
}
183-
Debugging.log(`The version ${version} was determined to be valid.`, this.context.eventStream);
184180
}
185181

186182
private async getReleasesInfo(mode: DotnetInstallMode): Promise<IDotnetListVersionsResult>

vscode-dotnet-runtime-library/src/EventStream/EventStreamEvents.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -623,22 +623,7 @@ export class DotnetInstallCancelledByUserError extends DotnetInstallExpectedAbor
623623
public readonly eventName = 'DotnetInstallCancelledByUserError';
624624
}
625625

626-
export class DotnetDebuggingMessage extends IEvent
627-
{
628-
public readonly eventName = 'DotnetDebuggingMessage';
629-
public readonly type = EventType.DotnetDebuggingMessage;
630-
631-
constructor(public readonly message: string)
632-
{
633-
super();
634-
this.message = message;
635-
}
636626

637-
public getProperties()
638-
{
639-
return { message: this.message };
640-
}
641-
}
642627

643628
export class DotnetNonZeroInstallerExitCodeError extends DotnetAcquisitionError
644629
{

vscode-dotnet-runtime-library/src/EventStream/EventType.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export enum EventType
1818
DotnetAcquisitionAlreadyInstalled,
1919
DotnetAcquisitionInProgress,
2020
DotnetUninstallMessage,
21-
DotnetDebuggingMessage,
2221
DotnetTotalSuccessEvent,
2322
OfflineInstallUsed,
2423
OfflineWarning,

0 commit comments

Comments
 (0)