A team encountered a failure in our Azure DevOps build pipeline when using the Microsoft-hosted agent windows-2019. The pipeline suddenly started failing with errors indicating that the configuration was no longer supported. This happens because Microsoft has deprecated the windows-2019 hosted agents, making them unavailable for new builds.
As a solution, we can choose a different agent. In this case, we switched from windows-2019 to windows-2022. However, when running the pipeline again on windows-2022, it fails during the NuGet restore step with the following error.
##[error]The nuget command failed with exit code(1) and error(Error parsing solution file at D:\a\1\s\MYSetupAPI\MYSetupAPI.sln: Exception has been thrown by the target of an invocation. Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.)
The windows-2022 agent comes with newer versions of Visual Studio and MSBuild compared to the windows-2019 agent. However, the NuGet restore step fails because it attempts to use an older assembly that is not present on the agent. To resolve this without specifying a particular version, we updated the YAML pipeline as follows.
Instead of old Script below:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
use below step:
- task: NuGetToolInstaller@1
No comments:
Post a Comment