Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. (MSB3971) #6256

Closed
FRazban opened this issue May 12, 2021 · 12 comments
Assignees
Labels
needs-more-info Not enough information has been provided. Please share more detail as requested. question

Comments

@FRazban
Copy link

FRazban commented May 12, 2021

/Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Microsoft.Common.CurrentVersion.targets(3,3): Error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. (MSB3971)

I am using visual studio for mac and my version is up to date, if I create a new project with version dotnet 5 all is well but as soon as I try to build the project I have worked on windows I get this error. I have also installed the latest version of SDK

@GrabYourPitchforks
Copy link
Member

/cc @rainersigwald - can you assist?

@mairaw
Copy link
Contributor

mairaw commented May 12, 2021

What SDK version and VS for Mac version are you running?
Make sure you have the minimum version required for the SDK version:
https://dotnet.microsoft.com/download/dotnet/5.0

@mairaw mairaw added the needs-more-info Not enough information has been provided. Please share more detail as requested. label May 12, 2021
@rainersigwald
Copy link
Member

In addition to Maira's questions, do you have a global.json file in your repo? If so can you share its contents?

@no-response
Copy link

no-response bot commented May 19, 2021

This issue has been automatically closed due to no response from the original author. Please feel free to reopen it if you have more information that can help us investigate the issue further.

@no-response no-response bot closed this as completed May 19, 2021
@Richbward
Copy link

I'm getting the same problem using VS2019 Preview (I'm on Windows 10). When I click on Help/Check for Updates it comes back with, “Visual Studio is up to date”.

Per your response above I then went to https://dotnet.microsoft.com/download/dotnet/5.0 and chose SDK 5.0.300 for Windows x64. When finished it reported:
.NET SDK 5.0.203
.NET Runtime 5.0.6

I tried running the same command again that originally raised this error: docker build . -t
Output: the same error:
ERROR [build 6/6] RUN dotnet build "SpecialOffers.csproj" -c Release -o /api/build 1.6s

[build 6/6] RUN dotnet build "SpecialOffers.csproj" -c Release -o /api/build:
#13 0.627 Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
#13 0.627 Copyright (C) Microsoft Corporation. All rights reserved.
#13 0.627
#13 1.163 Determining projects to restore...
#13 1.427 All projects are up-to-date for restore.
#13 1.550 /usr/share/dotnet/sdk/3.1.409/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/src/SpecialOffers.csproj]

This is my Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["SpecialOffers/SpecialOffers.csproj", "SpecialOffers/"]
RUN dotnet restore "SpecialOffers/SpecialOffers.csproj"
COPY . .
WORKDIR "/src/SpecialOffers"
RUN dotnet build "SpecialOffers.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "SpecialOffers.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "SpecialOffers.dll"]

@rainersigwald
Copy link
Member

@Richbward

These parts of that output

Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
...
/usr/share/dotnet/sdk/3.1.409/Microsoft.Common.CurrentVersion.targets

indicates that you're using .NET Core SDK 3.1.409, rather than .NET SDK 5.0.xxx, which is required to target .NET 5.0.

I tried using your Dockerfile and it seems to work fine to me--the dotnet/sdk:5.0 container has 5.0.300 installed.

One difference I find interesting is that the step number is 7/7 instead of 6/6 as you posted:

 => [build 6/7] WORKDIR /src/SpecialOffers                                                                         0.1s
 => [build 7/7] RUN dotnet build "SpecialOffers.csproj" -c Release -o /app/build                                   2.1s
 => [publish 1/1] RUN dotnet publish "SpecialOffers.csproj" -c Release -o /app/publish                             1.5s

Is that your full, exact Dockerfile?

@ins0mniaque
Copy link

ins0mniaque commented Jun 16, 2021

I've had the same problem that @FRazban had with Visual Studio for Mac. The fix was to set the .NET Core SDK location to the non-symlinked binary.

In my case, in Preferences > Projects > SDK Locations > .NET Core, I had /usr/local/bin/dotnet as SDK location, but it said "Not found". Running which dotnet in a terminal gives me /usr/local/bin/dotnet.

I tried using the file browser to select /usr/local/bin/dotnet again, but it selected /usr/local/share/dotnet/dotnet, the "real" location of the binary.

Once the .NET Core SDK location was set to /usr/local/share/dotnet/dotnet, I could build .NET 5.0 projects again (it was working previously, before I updated Visual Studio for Mac).

@nifesimii
Copy link

I have the same issue everytime i run dotnet build even though my sdk is set to the right location.
`Ademoyes-MacBook-Air:MvcMovie ademoyeoluwanifesimi$ dotnet build
Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

Determining projects to restore...
Restored /Users/ademoyeoluwanifesimi/Projects/MvcMovie/MvcMovie/MvcMovie.csproj (in 1.1 sec).
/usr/local/share/dotnet/x64/sdk/3.1.416/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/Users/ademoyeoluwanifesimi/Projects/MvcMovie/MvcMovie/MvcMovie.csproj]

Build FAILED.

/usr/local/share/dotnet/x64/sdk/3.1.416/Microsoft.Common.CurrentVersion.targets(1177,5): error MSB3971: The reference assemblies for ".NETFramework,Version=v5.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK. [/Users/ademoyeoluwanifesimi/Projects/MvcMovie/MvcMovie/MvcMovie.csproj]
0 Warning(s)
1 Error(s)

`

@rainersigwald
Copy link
Member

@nifesimii Looks like you are running .NET Core SDK 3.1.416, which did not understand how to target .NET 5.0+, and the error message is accurate.

even though my sdk is set to the right location

How are you setting this?

@akutishevsky
Copy link

akutishevsky commented Dec 26, 2022

In case someone has a similar issue on the Visual Studio for Mac. After updating to MacOS Ventura all projects started throwing same errors. In my situation the next steps helped:

  1. Open the Visual Studio
  2. Go to Preferences > SDK Locations
  3. For the Location field use /usr/local/share/dotnet/x64/dotnet instead of the /usr/local/share/dotnet/dotnet path.

This one applies for dotnet 6.0 and 7.0, not sure it will help with the 5.0 version.

@brennhill
Copy link

I've got this same problem - it cannot find reference assemblies for .NET 6, despite the SDKs being found in visual studio.
I'm at a loss here.

@rainersigwald
Copy link
Member

@brennhill Please open a new issue with more information, including logs that show the version number of the SDK as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-info Not enough information has been provided. Please share more detail as requested. question
Projects
None yet
Development

No branches or pull requests

9 participants