AzurePipeline failing due to: The reference assemblies for .NETFramework,Version=v4.6.1 were not found
Asked Answered
S

2

22

I have an Azure pipeline setup for my builds. I have been running into this issue recently and cannot figure out a way to fix this:

##[error]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1220,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.6.1 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

About a week or so ago lots of our builds were failing, MS had changed something and we were getting this sort of thing:

[error]C:\Users\VssAdministrator\.nuget\packages\codegeneration.roslyn.buildtime\0.6.1\build\CodeGeneration.Roslyn.BuildTime.targets(73,5): Error CGR1001: CodeGeneration.Roslyn.Tool (dotnet-codegen) is not available, code generation won't run. Please check https://github.com/AArnott/CodeGeneration.Roslyn for usage instructions. 

However was able to solve this by explicitily adding a task to include the netcore2.1 sdk

    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: '2.x'

Now this issues is fixed we are now posed with the error complaining it cannot find .NET Framework 4.6.1.

Anyways any idea whats going on, this is driving me banannas - any advice or insight greatly appreciated.

Seamy answered 15/3, 2022 at 17:10 Comment(3)
This might sound obvious, but did you check that all of your build agents supporting 4.6.1? That's a very old version of .NET so it may be as simple as adding that back.Guzel
Thanks @Guzel - how do you check that I will look into it?Seamy
In the past I've remoted into and inspected the server(s) or container(s) the agents run on to see if they have the required setup/SDKs. I wish I could be more specific but I'm not using Azure DevOps these days.Guzel
T
30

The .Net framework version 4.6.1 has been deprecated by Azure DevOps Microsoft-hosted agent. For now, there are two kinds of Microsoft-hosted agents:

windows-2019 OR windows-latest: .Net framework version 4.7.2 and 4.8 preinstalled. This is documented here.

windows-2022: .Net framework version 4.8 preinstalled. This is documented here.

That is, you need to use self-hosted agent to use .Net framework 4.6.1 in the pipeline.

Thorlie answered 16/3, 2022 at 7:16 Comment(3)
Whilst this is mostly accurate, you can change the agent specification of a windows hosted agent in the agent pool to run Windows-2019 and this will address the issue. This is documented hereIllomened
vmImage: 'windows-2019' in the yml worked with 4.6.1 for me, so no need to use a self-hosted agent.Mcneal
vmImage: 'windows-2019' still working for .Net Framework 4.6.1Collard
D
11

From Agent pool - Change Agent Specification from Window-Latest to Window-2019 ,It seems MS has done some changes in default agent

Pipeline setting

Daugavpils answered 16/3, 2022 at 5:44 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Zippora
Specifically, updating the azure-pipelines.yml pool configuration section for the Pipeline to vmImage: 'windows-2019' from vmImage: 'windows-latest' resolved the issue for mePentosan

© 2022 - 2024 — McMap. All rights reserved.