The reference assemblies for framework ".NETFramework,Version=v4.6.2" were not found

.NetVisual Studio-2017

.Net Problem Overview


When trying to compile a solution, I get the following build error:

> Error MSB3644 The reference assemblies for framework > ".NETFramework,Version=v4.6.2" were not found. To resolve this, > install the SDK or Targeting Pack for this framework version or > retarget your application to a version of the framework for which you > have the SDK or Targeting Pack installed. Note that assemblies will be > resolved from the Global Assembly Cache (GAC) and will be used in > place of reference assemblies. Therefore your assembly may not be > correctly targeted for the framework you intend. > C:\RPR\Dev\Libraries\Common\Common.csproj C:\Program Files > (x86)\Microsoft Visual > Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 1111

I've tried installing the .NET Framework 4.6.2 SDK, as well as the 4.6 Targeting Pack, however both error that I already have it installed. I also tried installing Visual Studio 2017 but it still gives the same error.

Any ideas?

.Net Solutions


Solution 1 - .Net

It turns out that I had installed the .NET Framework v4.6.2, not the Developer Pack for 4.6.2. Doh!

https://www.microsoft.com/en-us/download/details.aspx?id=53321

Solution 2 - .Net

Windows -> Search -> Visual Studio Installer -> Modify -> Individual Components and check the right version

Solution 3 - .Net

Starting May, 2019 you can build your project on net20 up to net48 (including ne461) any machine with at least MSBuild or the .NET Core SDK installed without the need of Developer Pack installed.

If .NET Core SDK installed in you machine, Add the nuget package Microsoft.NETFramework.ReferenceAssemblies to your project

	<ItemGroup>
		<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
			<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
			<PrivateAssets>all</PrivateAssets>
		</PackageReference>		
	</ItemGroup>

The package include all ReferenceAssemblies starting net20 up to net48

These packages enable building .NET Framework projects on any machine with at least MSBuild or the .NET Core SDK installed plus other scenarios.

For more details: https://github.com/Microsoft/dotnet/tree/master/releases/reference-assemblies

Solution 4 - .Net

Installing the 4.6.2 Developer Pack did not work for me.

I had to install .NET Framework 4.6 Targeting Pack

Solution 5 - .Net

I was getting the exact same error when building except it was for ".NETFramework,Version=v4.7.1".

I downloaded the Developer pack for 4.7.1 from here: https://www.microsoft.com/en-us/download/confirmation.aspx?id=56119

The pack installed these programs on the target machine (my build server).

  • Microsoft .NET Framework 4.7.1 SDK
  • Microsoft .NET Framework 4.7.1 Targeting Pack
  • Microsoft .NET Framework 4.7.1 Targeting Pack (ENU)

When I tried building again, I didn't get the error anymore and the build succeeded.

Solution 6 - .Net

For 4.7.2 issue I have to go here: https://dotnet.microsoft.com/download/dotnet-framework/net472

Install the Download .NET Framework 4.7.2 Developer Pack as displayed in the image to fix the issue.

enter image description here

Solution 7 - .Net

I was using ubuntu and faced the same problem. Even after I've downloaded latest vscode and mono for ubuntu it was not working. Then I found this.
Basically if you've installed mono then go to settings and set >"omnisharp.useGlobalMono": "always".

hope it fix your issue.

Solution 8 - .Net

Check the installed .net framework on your development machine, it must be the same as project file targeting. You need to install the .net framework which the project file targeting after that try again the errors and warnings will disappear.

Solution 9 - .Net

you can find this omnisharp setting inside Visual Studio C# extensions settings and go to the botton.

enter image description here

Solution 10 - .Net

Download required SDK package with link , .net framework 4.6.2 developer pack download-link and install. Restart the server, now build will be successful.

You can check dotnet version with dotnet --info

Solution 11 - .Net

In my case, (I'm embarrassed to admit) I had a website loaded as a project and forgot to set it to No Build.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJustinView Question on Stackoverflow
Solution 1 - .NetJustinView Answer on Stackoverflow
Solution 2 - .NetCata HoteaView Answer on Stackoverflow
Solution 3 - .NetM.HassanView Answer on Stackoverflow
Solution 4 - .NetRubanovView Answer on Stackoverflow
Solution 5 - .NetJamie ButterworthView Answer on Stackoverflow
Solution 6 - .NetRaghavView Answer on Stackoverflow
Solution 7 - .NetSaswata DuttaView Answer on Stackoverflow
Solution 8 - .NetPSTechView Answer on Stackoverflow
Solution 9 - .NetRo DView Answer on Stackoverflow
Solution 10 - .NetAditya YView Answer on Stackoverflow
Solution 11 - .NetJeremy HodgeView Answer on Stackoverflow