Reputation: 6557
We have a Visual Studio project in Azure Devops. We are using VS2019.
The build was working with this project. However, earlier this week the build stopped working. The error message is below.
I checked the build server. The .Net framework 4 is installed. Also, the project framework has not changed.
It looks like the MSBUILD is trying to use VS2022.
How can I change the build to use the VS2019 MSBUILD? How is this set?
How can I correct the below error?
##[error]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1217,5):
Error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found
Upvotes: 8
Views: 8692
Reputation: 1088
Think I figured it out myself. In your yaml file, change the target vmImage from windows-latest, to windows-2019.
pool:
vmImage: 'windows-2019'
Upvotes: 17
Reputation: 121
It might be caused by environment variables of Azure Agent server(build serer).
You can review environment variables via
project setting - agent pools - your agent pool - agents tab - agent - capabilities tab
check value of MSBuild variable, to see if it point to "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin"
if so, login Azure Agent server then update MSBuild variable to VS2019.
Upvotes: 2