I have an Azure Pipeline configured to build and deploy a .NET 5 application to an on prem server. This works fine for .NET 5, but after upgrading to .NET 6, I had to update the vmImage from windows-latest to windows-2022, as windows-latest doesn't have the .NET 6 SDKs on (according to https://github.com/dotnet/core/issues/6907). This was the error I received
The nuget command failed with exit code(1) and error(C:\Program Files\dotnet\sdk\5.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.
That makes sense, so I've updated the vmImage to windows-2022, and it now gets past that bit, but the pipeline now fails on the webpack task.
Original YAML file (failed on NuGet task due to not having .NET 6 tools available)
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'
Updated YAML file
trigger:
- develop
pool:
vmImage: 'windows-latest'
...Everything else the same as original file above...
This now fails on the script command to run 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\_temp\501f6f1d-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
In vague attempts at fixing the problem I've also tried changing the Npm task to just a normal script task with npm install and npm-install --save-dev with no luck. I've also put the npm install and webpack commands into a single script task but the same error occurs.