in src/scaffolding/wizard/netCore/NetCoreGatherInformationStep.ts [36:79]
public async prompt(wizardContext: NetCoreScaffoldingWizardContext): Promise<void> {
await this.ensureNetCoreBuildTasks(wizardContext);
const projectInfo = await getNetCoreProjectInfo('GetProjectProperties', wizardContext.artifact);
if (projectInfo.length < 2) {
throw new Error(localize('vscode-docker.scaffold.netCoreGatherInformationStep.noProjectInfo', 'Unable to determine project info for \'{0}\'', wizardContext.artifact));
}
if (!wizardContext.netCoreAssemblyName) {
wizardContext.netCoreAssemblyName = projectInfo[0]; // Line 1 is the assembly name including ".dll"
}
if (!wizardContext.netCoreRuntimeBaseImage || !wizardContext.netCoreSdkBaseImage) {
this.targetFramework = projectInfo[1]; // Line 2 is the <TargetFramework> value, or first item from <TargetFrameworks>
const regexMatch = /net(coreapp)?([\d.]+)/i.exec(this.targetFramework);
if (!regexMatch || regexMatch.length < 3) {
throw new Error(localize('vscode-docker.scaffold.netCoreGatherInformationStep.noNetCoreVersion', 'Unable to determine .NET target framework version for \'{0}\'', wizardContext.artifact));
}
const [, , netCoreVersionString] = regexMatch;
// semver.coerce tolerates version strings like "5.0" which is typically what is present in the .NET project file
const netCoreVersion = semver.coerce(netCoreVersionString);
const tagSuffix = wizardContext.netCorePlatformOS === "Linux" ? linuxTagSuffix : '';
wizardContext.netCoreRuntimeBaseImage = wizardContext.platform === '.NET: ASP.NET Core' ? `${aspNetBaseImage}:${netCoreVersion.major}.${netCoreVersion.minor}${tagSuffix}` : `${consoleNetBaseImage}:${netCoreVersion.major}.${netCoreVersion.minor}${tagSuffix}`;
wizardContext.netCoreSdkBaseImage = `${netSdkImage}:${netCoreVersion.major}.${netCoreVersion.minor}${tagSuffix}`;
}
if (!wizardContext.serviceName) {
wizardContext.serviceName = getValidImageNameFromPath(wizardContext.artifact);
}
if (!wizardContext.dockerfileDirectory) {
// For .NET Core, the Dockerfile is always adjacent the artifact (csproj)
wizardContext.dockerfileDirectory = path.dirname(wizardContext.artifact);
}
// No need to set dockerBuildContext because the superclass will set it to the proper value (the workspace root)
await super.prompt(wizardContext);
}