This commit is contained in:
alexyaang 2023-05-03 11:28:40 -04:00
Родитель 14b7601c11
Коммит 68f0aadb70
3 изменённых файлов: 19 добавлений и 1 удалений

Просмотреть файл

@ -1015,6 +1015,21 @@
"type": "boolean",
"description": "%vscode-docker.tasks.docker-build.netCore.useSdkBuild%",
"default": false
},
"configuration": {
"anyOf": [
{
"type": "string"
},
{
"type": "string",
"enum": [
"Debug",
"Release"
]
}
],
"description": "%vscode-docker.tasks.docker-build.netCore.configuration%"
}
},
"required": [

Просмотреть файл

@ -61,6 +61,7 @@
"vscode-docker.tasks.docker-build.netCore.description": "Options for building .NET projects in Docker.",
"vscode-docker.tasks.docker-build.netCore.appProject": "The .NET project (.csproj, .fsproj, etc.) to build.",
"vscode-docker.tasks.docker-build.netCore.useSdkBuild": "Whether to use the .NET Core SDK to build the project.",
"vscode-docker.tasks.docker-build.netCore.configuration": "The configuration flag in .NET that modifies runtime behavior.",
"vscode-docker.tasks.docker-build.node.description": "Options for building Node.js applications in Docker.",
"vscode-docker.tasks.docker-build.node.package": "The path to the package.json for the application.",
"vscode-docker.tasks.docker-build.python.description": "Options for building Python applications in Docker.",

Просмотреть файл

@ -28,6 +28,7 @@ export interface NetCoreTaskOptions {
configureSsl?: boolean;
enableDebugging?: boolean;
useSdkBuild?: boolean;
configuration?: string;
}
export interface NetCoreBuildTaskDefinition extends DockerBuildTaskDefinitionBase {
@ -301,10 +302,11 @@ export class NetCoreTaskHelper extends TaskHelper {
* @see {@link https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container} for further information
*/
private async buildWithDotnetSdk(context: DockerBuildTaskContext, buildDefinition: DockerBuildTaskDefinition): Promise<void> {
const configuration = buildDefinition.netCore?.configuration ? `-c ${buildDefinition.netCore?.configuration} ` : '';
const publishFlag = NetCoreTaskHelper.isWebApp ? '-p:PublishProfile=DefaultContainer' : '/t:PublishContainer';
const [runtimeOs, runtimeArch] = this.getOsAndArch(buildDefinition);
const imageNameInfo = parseDockerLikeImageName(buildDefinition.dockerBuild.tag);
const sdkBuildCommand = `dotnet publish --os ${runtimeOs} --arch ${runtimeArch} ${publishFlag} -c Debug -p:ContainerImageName=${imageNameInfo.image} -p:ContainerImageTag=${imageNameInfo.tag}`;
const sdkBuildCommand = `dotnet publish --os ${runtimeOs} --arch ${runtimeArch} ${publishFlag} ${configuration}-p:ContainerImageName=${imageNameInfo.image} -p:ContainerImageTag=${imageNameInfo.tag}`;
await context.terminal.execAsyncInTerminal(
sdkBuildCommand,
{