25

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?

4
  • It is not so obvious to me that cobbling together everything you need to build UWP apps is practical or possible. They do march to a different drummer. The dedicated MSDN page that talks about setting up automated builds is here. Commented Mar 15, 2018 at 9:08
  • So your advice is to use the pre-configured UWP build step on VSTS? Commented Mar 15, 2018 at 9:26
  • When you use the documented procedure you'll have a much easier time finding help. Assuming you would need any, expectation is that you don't. Commented Mar 15, 2018 at 9:32
  • Perhaps (not convinced it won't present its own set of problems though). But I prefer to use my own custom build step as the pre-configured one gives me about 1% of the functionality I need. What surprises me though is that off the three mobile platforms (iOS, Android, UWP), MSBuild struggles to build the one that you'd expect to be the easiest...considering they are both from the same company. Commented Mar 15, 2018 at 10:38

9 Answers 9

36

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 16.4 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.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

13

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.

2 Comments

This was my issue too. global.json was not in the Solution Explorer in Visual Studio, but sure enough there it was in the project root directory.
This is the real answer. Nobody tries to create/build NET5 projects without it installed, that makes no sense. But this catch here can bite you real good when upgrading from 3.1 and such as nobody remembers about this config file.
10

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

Comments

4

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:

enter image description here

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.

7 Comments

thanks a bunch, I'll try this. The 'Universal Windows Platform development' workload is not available in the Build Tools installer though. That screenshot you've posted appears to be from a VS Enterprise installer.
@Ash, ahahah, I forgot they are different. But copy the directly should be work to resolve this error. Now I updated the answer, you can check if it works for you.
".NET framework SDK"? You should say Windows SDK directly, and it can be downloaded separately, developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
@Leo I should mention that I'm working with C# (I've edited tags for my question). Given that, do I still need the SDKs for C++? I had already tried installing the WIndows 10 SDK (10.0.16299.0) for UWP: C#, VB, JS, before I posted this question, so I guess that does not work.
@Leo I can see that I do have a folder for the .NETCore v5.0 framework at the location you mentioned on machine 1. I don't have access to machine 2 at the moment, but I'll try this when I do and update you.
|
3

The below steps worked for me.

In Visual Studio open View -> Terminal and enter: dotnet new global.json

Open the root folder of the solution and edit the newly created file "global.json" the exact name of the .net version installed must be entered.

To view all installed .net core sdk's , enter dotnet --list-sdks in command.

enter image description here

add the correct version to the global.json file, the right-click solution, and select Restore Nuget Packages or restart the visual studio.

The global.json will look like this

enter image description here

Comments

1

See you have Microsoft Visual Studio v16.8 or above.

To update the VS version -> Help -> Check for Updates

Comments

1

This error is displayed if the .NET 5.0 SDK is not installed. Be careful, you must download the proper sdk: dotnet-sdk-5.0.401-win-x64.exe or dotnet-sdk-5.0.401-win-x86.exe depending on your installation (in the case of Visual Studio Code or your Windows) In the path https: // dotnet.microsoft.com/download/dotnet/5.0 you can download.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
I had to install both the .NET SDK and the AspNet Core Runtime to resolve the issue. Googling led me to this post. Thank you @Juan for sharing your knowledge.
0

I had the same error message

enter image description here

1- Open Visual Studio Installer 2- Updat the version of Visual Studio 2019 to 16.11 or Upper 3- Restart your Project

Comments

0

I had the same error and solved it by below steps:
In my case, the system uses .Net Core 3.1 and ignores all the new versions SDK like 6.0 or 7.0.
I did these and the problem was solved:

at the first run dotnet --version in CMD to ensure that you're using the correct version.
then run where dotnet (on the window) to see which dotnet ran in CLR.
if this command has more than one result like

c:\program files\dotnet\sdk\3.1
c:\program files (86)\dotnet\7.0

remove the wrong version physically (in my case it was 3.1) and then restart the visual studio.
now run your project.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.