Azure Pipeline webpack 脚本使用 windows-2022 失败
Azure Pipeline webpack script failing using windows-2022
我配置了一个 Azure Pipeline,用于构建 .NET 5 应用程序并将其部署到本地服务器。这适用于 .NET 5,但在升级到 .NET 6 后,我不得不将 vmImage
从 windows-latest
更新为 windows-2022
,因为 windows-latest
没有.NET 6 SDKs on(根据 https://github.com/dotnet/core/issues/6907)。这是我收到的错误
The nuget command failed with exit code(1) and error(C:\Program
Files\dotnet\sdk.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141,5):
error NETSDK1045: The current .NET SDK does not support targeting .NET
6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.
这是有道理的,所以我已经将 vmImage
更新为 windows-2022
,现在它已经超过了那个位,但是管道现在在 webpack 任务上失败了。
原始 YAML 文件(由于没有可用的 .NET 6 工具,NuGet 任务失败)
trigger:
- develop
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: Npm@1
inputs:
command: 'ci'
workingDir: '$(Build.SourcesDirectory)/GIFrameworkMaps.Web'
- script: webpack --mode=development
workingDirectory: '$(Build.SourcesDirectory)/GIFrameworkMaps.Web'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'giframeworkmaps-$(Build.SourceVersion)'
publishLocation: 'Container'
已更新 YAML 文件
trigger:
- develop
pool:
vmImage: 'windows-latest'
...Everything else the same as original file above...
运行 webpack
的脚本命令现在失败了
Generating script.
Script contents: webpack --mode=development
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp1f6f1d-71f5-4286-ac14-dda4b0c8948c.cmd""
'webpack' is not recognized as an internal or external command, operable program or batch file.
##[error]Cmd.exe exited with code '1'. Finishing: CmdLine
在解决问题的模糊尝试中,我还尝试将 Npm
任务更改为正常的 script
任务 npm install
和 npm-install --save-dev
但没有成功.我还将 npm install
和 webpack
命令放入单个 script
任务中,但发生了同样的错误。
windows-2022 image, while it is installed on windows-latest.
默认没有安装 Webpack
但是,您可以轻松地将其安装为构建管道的一部分:
npm install webpack -g
我配置了一个 Azure Pipeline,用于构建 .NET 5 应用程序并将其部署到本地服务器。这适用于 .NET 5,但在升级到 .NET 6 后,我不得不将 vmImage
从 windows-latest
更新为 windows-2022
,因为 windows-latest
没有.NET 6 SDKs on(根据 https://github.com/dotnet/core/issues/6907)。这是我收到的错误
The nuget command failed with exit code(1) and error(C:\Program Files\dotnet\sdk.0.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0.
这是有道理的,所以我已经将 vmImage
更新为 windows-2022
,现在它已经超过了那个位,但是管道现在在 webpack 任务上失败了。
原始 YAML 文件(由于没有可用的 .NET 6 工具,NuGet 任务失败)
trigger:
- develop
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: Npm@1
inputs:
command: 'ci'
workingDir: '$(Build.SourcesDirectory)/GIFrameworkMaps.Web'
- script: webpack --mode=development
workingDirectory: '$(Build.SourcesDirectory)/GIFrameworkMaps.Web'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'giframeworkmaps-$(Build.SourceVersion)'
publishLocation: 'Container'
已更新 YAML 文件
trigger:
- develop
pool:
vmImage: 'windows-latest'
...Everything else the same as original file above...
运行 webpack
的脚本命令现在失败了Generating script.
Script contents: webpack --mode=development
========================== Starting Command Output ===========================
"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp1f6f1d-71f5-4286-ac14-dda4b0c8948c.cmd""
'webpack' is not recognized as an internal or external command, operable program or batch file.
##[error]Cmd.exe exited with code '1'. Finishing: CmdLine
在解决问题的模糊尝试中,我还尝试将 Npm
任务更改为正常的 script
任务 npm install
和 npm-install --save-dev
但没有成功.我还将 npm install
和 webpack
命令放入单个 script
任务中,但发生了同样的错误。
windows-2022 image, while it is installed on windows-latest.
默认没有安装 Webpack但是,您可以轻松地将其安装为构建管道的一部分:
npm install webpack -g