The reference assemblies for framework .NETCore, Version=v5.0 were not found

懵懂的女人 提交于 2021-02-07 12:29:24

问题


I have a UWP project that was created using Visual Studio 2017. It builds fine on this machine (machine 1).

However, when I copy the project over to a machine (machine 2) where I only have the Visual Studio 2017 Build Tools installed, and attempt to build it using MSBuild, I get the following error:

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
(1126,5): error MSB3644: The reference assemblies for framework ".NETCore,Version=v5.0" 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 framewo
rk for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assemb
ly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted
 for the framework you intend. [<path_to_my_UWP_project>\UWP.csproj]

I suspect the need for .NetCore v5.0 arises from this line in my UWP.csproj file:

< PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.0.1" />

I do a nuget restore before I build on machine 2, and I can see that microsoft.netcore.universalwindowsplatform successfully gets restored under < C_Users_me >/.nuget/packages, and so does microsoft.netcore.

On machine 1 however, only microsoft.netcore.universalwindowsplatform gets restored but it still builds fine via Visual Studio.

Question: Why am I getting this error and how do I fix the problem?


回答1:


The reference assemblies for framework .NETCore, Version=v5.0 were not found

According to the error log, it seems you are missing the .NET framework SDK (. NET core, v5.0) on your machine 2. You can check the it from following directory:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0

To install it, make sure you are install following individual components:

If you still have that error, please try to copy the directory C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v5.0 from machine 1 to machine 2.

Hope this helps.




回答2:


I was getting the same error message. The resolution was to install the latest version of Visual Studio 2019. I had version 16.6 installed on my computer. I needed version 16.8 installed. Once I did the install, the error message went away.

Initial reason for this issue: I had received a VS C# solution from another individual. Apparently there was something in the solution that stated it required some library (.NETFramework v=5.0) which was not in 1.64 but was in 16.8.

The help instructions on the VS error message did not help; there is currently no .NETFramework, version=v5.0. There is only a .NET Core Version=5.0 or a .NetFramework Version=v4.8

This gitHub post lead me to the correct soltuion.




回答3:


You need to use Visual Studio 2019 16.8 Preview 2 or newer to use .NET 5 Preview 8. .NET 5 Download it from here https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-preview




回答4:


I was chasing the exact same issue but for all I could see, I had the right SDK installed. As it turned out, I had caused the issue myself by placing a global.json in the root directory with the SDK version pinned to 3.1.404. dotnet was honouring the global.json settings and hence could not locate the reference assemblies for 5.0. Removing the global.json fixed the issue for me.



来源:https://stackoverflow.com/questions/49268779/the-reference-assemblies-for-framework-netcore-version-v5-0-were-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!