Visual Studio Build in Azure DevOps Pipelines failing on latest Windows vmImage
Problem statement
In the past couple of years, I have learned how to work with Azure DevOps Pipelines (Pipelines & Release Pipelines) using the Classic Editor. Last week, I started to play around with Azure DevOps YAML Pipelines. For some reason, I wasn’t able to build my Database Project using the latest vmImage for windows in Azure DevOps.
My Pipeline YAML file looked like this:
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: windows-latest
steps:
- task: VSBuild@1
inputs:
solution: '**\*.sqlproj'
As you can see, I wanted to use the windows-latest vmImage.
The error message I received during the build process in my Azure DevOps YAML Pipeline was :
##[error]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1229,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
I wasn’t sure how to solve this issue, and when I was using my on-premise Agent Pool, the Database Project was able to build successfully.
After doing some research, I didn’t really find any relevant information about this error. So, I tried to find out what was going on and how to solve this issue.
Solution
After some thinking, I finally realized that I should be validating my Database Project since I’m not aware if I’m even possible to install extensions on the Azure DevOps Default Agent.
I opened my Database Project and realized that I should be looking into my Database Project settings. Especially, since that would be the logical place to keep that kind of configuration. So I went through the different tabs in the properties window until I reached the SQLCLR tab.
In the SQLCLR tab, you can define the Target framework version you would like to use.
As you can see in the screenshot above, I chose the .NET Framework 4.7.2 version. if I clicked on the “Install other frameworks…” option, I reached a Microsoft webpage with all supported .NETFramework version listed.
You can reach that page using the following URL: https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk
I also found out that the .NETFramework version I was using by default was already out of support for a long time.
After updating the .NETFramework in my Database Project and committing this change to my repository, I finally was able to successfully build my Database Project on the Default Azure DevOps Agent.