Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Documentation/contributing-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ We use and recommend the following workflow:
- Please follow our [Commit Messages](contributing.md#commit-messages) guidance.
5. Add new tests corresponding to your change, if applicable.

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).
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.
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.

Expand Down
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ $successColor = "Green"

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

try
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ NC=`tput sgr0`
echo ""
echo "----------- Bundling Install Scripts -----------"
echo ""
curl https://dot.net/v1/dotnet-install.ps1 --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
curl https://dot.net/v1/dotnet-install.sh --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
curl https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.ps1 --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.ps1"
curl https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh --retry 2 -o "./vscode-dotnet-runtime-library/install scripts/dotnet-install.sh"
if [ $? -eq 0 ];
then
echo ""
Expand Down
2 changes: 1 addition & 1 deletion mock-webpack.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The library doesn't get webpacked, but it needs the copy of items that would normally be webpacked
# ... into the SDK or Runtime Extension for it to run in local dev scenarios.
Copy-Item ".\vscode-dotnet-runtime-library\distro-data\" -Destination ".\vscode-dotnet-runtime-library\dist\Acquisition\" -Recurse -Force
Copy-Item ".\vscode-dotnet-runtime-library\install scripts\" -Destination ".\vscode-dotnet-runtime-library\dist\utils\" -Recurse -Force
Copy-Item ".\vscode-dotnet-runtime-library\install scripts\" -Destination ".\vscode-dotnet-runtime-library\dist\" -Recurse -Force
2 changes: 1 addition & 1 deletion mock-webpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ echo ""
echo "----------- Copying Library Webpacked Dependencies -----------"
echo "" # See the build.ps1 for more details on why we do this
cp -r ./vscode-dotnet-runtime-library/distro-data ./vscode-dotnet-runtime-library/dist/Acquisition
cp -r "./vscode-dotnet-runtime-library/install scripts" ./vscode-dotnet-runtime-library/dist/Utils
cp -r "./vscode-dotnet-runtime-library/install scripts" ./vscode-dotnet-runtime-library/dist
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import { IDotnetAcquireResult } from '../IDotnetAcquireResult';
import { IExtensionState } from '../IExtensionState';
import { IVSCodeExtensionContext } from '../IVSCodeExtensionContext';
import { CommandExecutor } from '../Utils/CommandExecutor';
import { Debugging } from '../Utils/Debugging';
import { FileUtilities } from '../Utils/FileUtilities';
import { IFileUtilities } from '../Utils/IFileUtilities';
import { getInstallFromContext, getInstallIdCustomArchitecture } from '../Utils/InstallIdUtilities';
Expand Down Expand Up @@ -246,8 +245,6 @@ To keep your .NET version up to date, please reconnect to the internet at your s
let acquisitionPromise = null;
if (globalInstallerResolver)
{
Debugging.log(`The Acquisition Worker has Determined a Global Install was requested.`, context.eventStream);

acquisitionPromise = this.acquireGlobalCore(context, globalInstallerResolver, install).catch(async (error: any) =>
{
await new CommandExecutor(context, this.utilityContext).endSudoProcessMaster(context.eventStream).catch(() => {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import
DotnetInstallScriptAcquisitionError,
EventBasedError,
} from '../EventStream/EventStreamEvents';
import { Debugging } from '../Utils/Debugging';
import { FileUtilities } from '../Utils/FileUtilities';
import { getInstallFromContext } from '../Utils/InstallIdUtilities';
import { WebRequestWorkerSingleton } from '../Utils/WebRequestWorkerSingleton';
Expand All @@ -27,26 +26,35 @@ export class InstallScriptAcquisitionWorker implements IInstallScriptAcquisition
private readonly fileUtilities: FileUtilities;
private readonly scriptFileEnding = os.platform() === 'win32' ? 'ps1' : 'sh';


protected readonly scriptFileName: string = 'dotnet-install';

constructor(private readonly context: IAcquisitionWorkerContext)
{
const scriptFileName = 'dotnet-install';
this.scriptFilePath = path.join(__dirname, 'install scripts', `${scriptFileName}.${this.scriptFileEnding}`);
this.scriptFilePath = path.join(__dirname, 'install scripts', `${this.scriptFileName}.${this.scriptFileEnding}`);
this.webWorker = WebRequestWorkerSingleton.getInstance();
this.fileUtilities = new FileUtilities();
}

private async getFallbackScript(): Promise<string>
{
const fallbackPath = this.getFallbackScriptPath();
if ((await this.fileUtilities.exists(fallbackPath)))
{
this.context.eventStream.post(new DotnetFallbackInstallScriptUsed());
return fallbackPath;
}

throw new EventBasedError('UnableToAcquireDotnetInstallScript', `Failed to Find Dotnet Install Script: ${this.scriptFileName}.${this.scriptFileEnding}. Please download .NET Manually.`);
}

public async getDotnetInstallScriptPath(): Promise<string>
{
try
{
Debugging.log('getDotnetInstallScriptPath() invoked.');
const script = await this.webWorker.getCachedData(`${this.scriptAcquisitionUrl}${this.scriptFileEnding}`, this.context);
if (!script)
{
Debugging.log('The request to acquire the script failed.');
throw new EventBasedError('NoInstallScriptPathExists', 'Unable to get script path.');
return this.getFallbackScript();
}

await this.fileUtilities.writeFileOntoDisk(script, this.scriptFilePath, this.context.eventStream);
Expand All @@ -55,19 +63,8 @@ export class InstallScriptAcquisitionWorker implements IInstallScriptAcquisition
}
catch (error: any)
{
Debugging.log('An error occurred processing the install script.');
this.context.eventStream.post(new DotnetInstallScriptAcquisitionError(error as Error, getInstallFromContext(this.context)));

// Try to use fallback install script
const fallbackPath = this.getFallbackScriptPath();
if ((await this.fileUtilities.exists(fallbackPath)))
{
Debugging.log('Returning the fallback script path.');
this.context.eventStream.post(new DotnetFallbackInstallScriptUsed());
return fallbackPath;
}

throw new EventBasedError('UnableToAcquireDotnetInstallScript', `Failed to Acquire Dotnet Install Script: ${error}`);
return this.getFallbackScript();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import
EventBasedError,
EventCancellationError
} from '../EventStream/EventStreamEvents';
import { Debugging } from '../Utils/Debugging';
import { getAssumedInstallInfo, getInstallFromContext } from '../Utils/InstallIdUtilities';
import { WebRequestWorkerSingleton } from '../Utils/WebRequestWorkerSingleton';

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

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

private async getReleasesInfo(mode: DotnetInstallMode): Promise<IDotnetListVersionsResult>
Expand Down
15 changes: 0 additions & 15 deletions vscode-dotnet-runtime-library/src/EventStream/EventStreamEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,22 +623,7 @@ export class DotnetInstallCancelledByUserError extends DotnetInstallExpectedAbor
public readonly eventName = 'DotnetInstallCancelledByUserError';
}

export class DotnetDebuggingMessage extends IEvent
{
public readonly eventName = 'DotnetDebuggingMessage';
public readonly type = EventType.DotnetDebuggingMessage;

constructor(public readonly message: string)
{
super();
this.message = message;
}

public getProperties()
{
return { message: this.message };
}
}

export class DotnetNonZeroInstallerExitCodeError extends DotnetAcquisitionError
{
Expand Down
1 change: 0 additions & 1 deletion vscode-dotnet-runtime-library/src/EventStream/EventType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export enum EventType
DotnetAcquisitionAlreadyInstalled,
DotnetAcquisitionInProgress,
DotnetUninstallMessage,
DotnetDebuggingMessage,
DotnetTotalSuccessEvent,
OfflineInstallUsed,
OfflineWarning,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import
DotnetAcquisitionInProgress,
DotnetAcquisitionStarted,
DotnetCustomMessageEvent,
DotnetDebuggingMessage,
DotnetExistingPathResolutionCompleted,
DotnetInstallExpectedAbort,
DotnetOfflineInstallUsed,
Expand Down Expand Up @@ -138,10 +137,6 @@ export class OutputChannelObserver implements IEventStreamObserver
const upgradeMessage = event as DotnetUpgradedEvent;
this.outputChannel.appendLine(`${upgradeMessage.eventMessage}:`);
break;
case EventType.DotnetDebuggingMessage:
const loggedMessage = event as DotnetDebuggingMessage;
this.outputChannel.appendLine(loggedMessage.message);
break;
case EventType.OfflineInstallUsed:
const offlineUsedMsg = event as DotnetOfflineInstallUsed;
this.outputChannel.appendLine(offlineUsedMsg.eventMessage);
Expand Down
50 changes: 0 additions & 50 deletions vscode-dotnet-runtime-library/src/Utils/Debugging.ts

This file was deleted.

1 change: 0 additions & 1 deletion vscode-dotnet-runtime-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export * from './test/mocks/MockObjects';
export * from './test/mocks/MockWindowDisplayWorker';
export * from './test/unit/TestUtility';
export * from './Utils/CommandExecutor';
export * from './Utils/Debugging';
export * from './Utils/ErrorHandler';
export * from './Utils/ExtensionConfigurationWorker';
export * from './Utils/FileUtilities';
Expand Down
6 changes: 5 additions & 1 deletion vscode-dotnet-runtime-library/src/test/mocks/MockObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class MockVersionResolver extends VersionResolver

export class MockInstallScriptWorker extends InstallScriptAcquisitionWorker
{
constructor(ctx: IAcquisitionWorkerContext, failing: boolean, private fallback = false)
constructor(ctx: IAcquisitionWorkerContext, private failing: boolean, private fallback = false)
{
super(ctx);
this.webWorker = failing ?
Expand All @@ -338,6 +338,10 @@ export class MockInstallScriptWorker extends InstallScriptAcquisitionWorker
}
else
{
if (this.failing)
{
throw new Error('Failed to Acquire Dotnet Install Script');
}
return super.getFallbackScriptPath();
}
}
Expand Down
Loading
Loading