The Specified SDK "Microsoft.NET.Sdk" was not Found - c#

So I'm using Rider without Visual Studio installed and its working fine for .NET
but for .NET Core I'm getting the error:
Project 'Test2' load failed: Das angegebene SDK "Microsoft.NET.Sdk" wurde nicht gefunden. → (the specified SDK "Microsoft.NET.Sdk" was not found) C:\Users****\RiderProjects\Test2\Test2\Test2.csproj at (0:0)
Project Creating Settings:
The Error when the project is being loaded which fails:
(the blue underline means "the specified SDK "Microsoft.NET.Sdk" was not found")
Rider Toolset and Build Settings:
Installed .Net Core Version:
Rider Version: JetBrains Rider 2018.1.4 Build #RD-181.5550.7
Hope it was detailed enough and you guys can help me to fix this error :)

#alphaaxmet
You're using a custom MSBuild version
Check your MSBuildSDKsPath env. variable, it should be equal to the path with your latest .net core sdk , e.g.: C:\Program Files\dotnet\sdk\2.1.302

Thanks to #Damir Beylkhanov 's and #Jura Gorohovsky 's answer, If you are experiencing The Specified SDK “Microsoft.NET.Sdk” was not Found error and you have installed JetBrains Rider 2019 or JetBrains Rider 2020 and Dot NET Core 3.1 on Windows 10 64 bit, see below instructions on How to Fix that;
You will need to use the MSBuild that comes with Dot NET Core 3.1 instead of the one that is provided by your installed Dot NET Runtime 3.x or 4.x
So here is how to locate and add the MSBuild that is needed for your Rider Jetbreains IDE if you are using Dot NET Core 3.1.
I was working with a Windows 10 64 bit OS and JetBrains Rider 2019.2.3 I do not know if this is How it works for other Windows platforms or previous versions of JetBrains Rider.
For 64 bit based Windows 10, after you install Dot NET Core 3.1 , your MSBuild.dll will be in this path C:\Program Files\dotnet\sdk\3.1.100
You may also consider adding the path C:\Program Files\dotnet\sdk\3.1.100 to your environment variables.
So here is How to do it.
Click Tools → Settings in JetBrains Rider 2019.2.3
Scroll down and locate Build, Execution, Deployment click on it to expand it.
Scroll down and locate Toolset and Build then click on it to open it.
Once you have opened Toolset and Build, find below the option for editing Use MSBuild version and click the Custom button to the right to browse for the MS Build you want to use.
Browse to the path where your Dot NET Core 3.1 is installed and select the MSBuild dll file there. In my case it was this path C:\Program Files\dotnet\sdk\3.1.100.
Once you have selected the MSBuild.dll that installed with your Dot NET Core 3.1, click OK and OK any other open windows then run your Project again. It should work fine now.
See below screenshot for where circled in red to follow through the same process as I did it on my JetBrains Rider IDE. The same screenshot herein also shows the path for MSBuild.dll in my Windows Desktop Computer.

I was getting this error when trying to load projects targetting .NET core (Project Sdk property Microsoft.NET.Sdk). My environment at the time of this issue was as follows:
.NET Core SDK 2.1.103 through 3.1.102 installed
JetBrains Rider 2019.3.4 installed
Visual Studio 2019 Professional 16.4.5 installed
Rider was able to open the project and solution absolutely fine, although VS 2019 kept complaining about missing SDK. This was a solution with 2 projects both with SDK as Microsoft.NET.Sdk. I then opened a solution that had a web project in it in VS 2019 i.e. Microsoft.NET.Sdk.Web. VS 2019 showed a prompt that said that I needed additional workloads to be installed. When I clicked ok, VS Installer launched and automatically selected "ASP.NET and web development" under workloads. After the installation finished, the web project opened fine but the project with Microsoft.NET.Sdk as the SDK continued to complain about missing SDK.
On further research, I came across this github issue where #akshita31 recommended installing .NET core build tools. Following this:
I relaunched VS 2019 installer
Looked under "Other Toolsets" (scroll at the bottom of the installer Workloads tab) and checked ".NET Core cross-platform development" and followed through.
After the installer finished, VS 2019 could open all projects without issues

I had this same error using the build tools docker container which only installs the azure build tools workload - not the netcore build tools required for Microsoft.Net.Sdk projects.
Solution - Modify dockerfile
The fix for me was to add the Component ID Workload for NetCore Build Tools to the dockerfile config
RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
--installPath C:\BuildTools `
--add Microsoft.VisualStudio.Workload.AzureBuildTools `
# <append the line below>
--add Microsoft.VisualStudio.Workload.NetCoreBuildTools `

Related

Using VS 2017 image, unable to build other projects in a solution which has one .NET Core 3 project

I have a solution with multiple projects, one of which targets .NET Core 3.
I need to build another project in the solution using both the VS 2019 image and the 2017 image. For the 2017 image, I don't need to build the .NET Core project; so I've disabled the build on that project using the VS Configuration Manager. However, the build still fails:
C:\Program Files\dotnet\sdk\2.2.108\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(137,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 3.0. Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0.
[C:\projects\antlr4parsetreevisualizer_visualizerTestCore_visualizerTestCore.csproj]
because of that one project.
How can I tell AppVeyor to ignore the project in this instance?
I tried explicitly setting the build: project: element, but to no avail.
appveyor.yml
We are going to add .NET Core 3.0 to Visual Studio 2017 image in the next update (https://github.com/appveyor/ci/issues/3158). In the meantime, you can use the following script to install .NET Core 3.0 during the build:
install:
- ps: Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile "$env:temp\dotnet-install.ps1"
- ps: '& $env:temp\dotnet-install.ps1 -Architecture x64 -Version "3.0.100" -InstallDir "$env:ProgramFiles\dotnet"'
Regarding project exclusion - I believe you can disable project building for specific configuration in Visual Studio IDE ("Configuration manager..."). However, for .NET Core projects I'd recommend going away from building a solution to building particular projects with dotnet build .... Additionally, if you need to publish .NET Core app publishing solution won't work with dotnet publish command.
Initially, I only had one .csproj file to build per configuration. Per build image, I passed the project to dotnet restore (in my case I also had to rework the matrix logic to depend on the appveyor_build_worker_image environment variable):
environment:
matrix:
- job_name: VS 2019 build
appveyor_build_worker_image: Visual Studio 2019
- job_name: VS 2017 build
appveyor_build_worker_image: Visual Studio 2017
# ...
for:
# ...
-
matrix:
only:
- appveyor_build_worker_image: Visual Studio 2017
configuration: ReleaseCI2017
build:
project: 2017\2017.csproj
before_build:
- cmd: dotnet restore 2017\2017.csproj
Once I did that, everything seems to work, even without downloading+installing .NET Core 3 in an install script.
appveyor.yml
Thread on AppVeyor support forum
But as it turned out, I needed to build two projects for each image. I've resolved this by using additional solution files to control which projects should be built under each image, instead of relying on the VS configuration manager.
I then pass each solution to the build: project element, and AppVeyor will only attempt to build the specific projects referenced by that solution.
appveyor.yml
AppVeyor log.

MSBuild fails for .NET Core SDK Version 2.2.202

After downloading and installing Visual Studio 2019 RC, I cannot run msbuild, and get the following error:
"Version 2.2.202 of the .NET Core SDK requires at least version 16.0.0 of MSBuild.
The current available version of MSBuild is 15.6.82.30579.
Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available."
I cannot find MSBuild version 16. The only version I find is this one here:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0"
.NET Core SDK versions 2.2.2XX and 2.1.6XX are intended to be used with Visual Studio 2019 and MSBuild 16.x.
.NET Core SDK versions for Visual Studio 2017 are 2.2.1XX and 2.1.5XX.
See this GitHub issue for more details.
Updating Visual Studio to the minimum supported version or above should fix this problem.
Some .NET Core versions also include fixes in MSBuild. They are distributed together with Visual Studio.
They put the minimum supported versions in the release notes of .NET Core.
For example: Announcing .NET Core 2.2 | .NET Blog
For people coming here because they have the in Azure DevOps Pipelines - here some pointers for that.
If you have a private agent pool configured (e.g. private build machine), you might want to update your machine to support a more recent MSBuild version. See other answers.
If you don't have configured a build agent and use a default agent pool provided by Azure DevOps itself (e.g. "Hosted" or VS2019), see if there is a newer Hosted one that supports your configuration. See screenshot below where to look.
I ran into this with our on-prem build server we use with GitHub Actions.
The solution was to run Visual Studio Installer and update Visual Studio Build Tools 2017 and 2019.
I realize this solution is very similiar to those above, but I wanted to speak to the situations where Visual Studio is not installed, but Build Tools are.
For anyone that is still coming across this issue. I found another way, to get around this without upgrading to VS 2019 or rolling back SDK 3.1. My experience is in TFS 2017 (on-prem). I'm the build engineer, not a developer.
I had an SDK 2.2 app that was failing after the install of 3.1.
Initially, it was causing the NuGet steps to fail. Research led to me asking the developers to add a global.json file having it point to 2.2. This fixed the NuGet errors.
Then MSBuild step was failing with similar to OPs message. Couldn't figure out why 3.1 was taking presedence over 2.2 when it was listed in global.json. So I started digging around in the SDK in stall folders (typically located in C:\Program Files\dotnet\sdk). I came across a file named minimumMSBuildVersion In the SDK\3.1.101 folder that file has version 16.3.0 of MSBuild listed. I then went to the SDK 2.2 folder and checked it there. It has version 15.3.0 which my build server has. I simply changed the version to this in the 3.1 folder and my build succeeded. I hope this helps anyone that may still be experiencing build issues when .Net Core SDK versions are updated on their TFS Build Servers.

How to install ASP.NET Core Blazor Language Services when not using VS 2017?

I am learning how to build a Blazor app from this tutorial.
The required tools are given as follows.
Install the .NET Core 2.1 SDK (2.1.300-preview2-008533 or later).
Install Visual Studio 2017 (15.7 Preview 5 or later) with the ASP.NET and web development workload selected.
Install the latest Blazor Language Services extension from the Visual Studio Marketplace.
Because downloading and installing VS 2017 take much time, I just installed the SDK. I also downloaded the language service (.vsix file) but don't know how to install it.
The following steps succeeded.
md test
cd test
dotnet new -i Microsoft.AspNetCore.Blazor.Templates
dotnet new blazor -o ba1
cd ba1
But the following
dotnet run
produces an error as follows:
CSC : error CS1617: Invalid option '7.3' for /langversion. Use '/langversion:?' to list supported values. [C:\Users\amd\test\ba1\ba1.csproj]
Question
It seems I need to install the language service, but how can it be done without VS 2017?
Edit
For answering the comment why I did not install VS 2017 and assume (I did not assume actually) it optional, see the excerpt taken from the tutorial.
The language service is for intellisense in Visual Studio. So if you are not using Visual Studio there is no need to install it. There is no blazor intellisense support for VSCode right now or something.
See here for the 7.3 error.

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

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?
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.
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.
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
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.
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.
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
See you have Microsoft Visual Studio v16.8 or above.
To update the VS version -> Help -> Check for Updates
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.
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

MSBUILD throws error: The SDK 'Microsoft.NET.Sdk' specified could not be found

I'm trying to build a solution using msbuild command line and I keep getting this error:
error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
The version of msbuild is the latest from microsoft visual studio 2017 tools. I'm using Windows Server 2012 R2 and the project uses .NET Core 2.0.
This is the command that I'm using:
msbuild.exe /p:Configuration=Release /t:restore C:\Projects\MyProject.sln
Complete log:
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 9/16/2017 3:09:03 PM.
Project "C:\Projects\MyProject.sln" on node 1 (restore target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
Project "C:\Projects\MyProject.sln" (1) is building "C:\Projects\Kernel\Kernel.csproj" (2) on node 1 (restore target(s)).
C:\Projects\MyProject.sln" (1) is building "C:\Projects\Kernel\Kernel.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
Done Building Project "C:\Projects\MyProject.sln" (1) is building "C:\Projects\Kernel\Kernel.csproj" (restore target(s)) -- FAILED.
Build FAILED.
"C:\Projects\MyProject.sln" (restore target) (1) ->
"C:\Projects\Kernel\Kernel.csproj" (restore target) (2) ->
C:\Projects\Kernel\Kernel.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
0 Warning(s)
11 Error(s)
I encountered this error after playing around with .Net Core 2.0 installation and seemingly messing it up. I would get this same error for dotnet restore, dotnet build or dotnet msbuild. Essentially, anything involving .Net Core and msbuild.
The error occurred because the MSBuildSDKsPath environment variable was still pointing to the old .Net Core 1.1 SDK.
To fix the problem, I manually set the MSBuildSDKsPath environment variable to point to 2.0.0's SDK path, which, for me with x64, this was at: C:\Program Files\dotnet\sdk\2.0.0\Sdks.
Basically, if you have Sdk="Microsoft.NET.Sdk" in your .csproj, then a folder with the same name should exist at your MSBuildSDKsPath location.
You were probably missing some components when you installed the VS tools
Download and run Build Tools for Visual Studio 2019. (On the VS download page, go to Tools for Visual Studio 2019 and then click download Build Tools for Visual Studio 2019)
Select Modify on Visual Studio Build Tools 2019 or your instance.
Select tab Individual components and check .NET Core SDK component
for me the solution was to set the sdk version in the global.json file:
and specify the correct version which exists in the C:\Program Files\dotnet\sdk folder. The VS installer uninstalled the previous version of .NET Core 3.0.100 and installed new one 3.1.100 so I had to change it from:
{ "sdk": { "version": "3.0.100" }}
to
{ "sdk": { "version": "3.1.100" }}
For me updating Visual Studio Build Tools resulted in the 'SDK not found' error.
The solution: run Visual Studio Installer, modify the Visual Studio (Build Tools) installation, and make sure the following workload is selected:
I got this issue in Mac OS and while using docker container and Azure this occurs because docker bash overrides MSBuildSDKsPath so don't
change any code just quit and restart your IDE (visual studio Mac) and run it again
I got the same issue when I tried to install x64 .Net Core SDK installer. Even the following dotnet --info command shows me that no SDK is found.
So, try to install x86 .Net Core SDK installer. That can help you.
I had the same problem and found solution here:
https://github.com/aspnet/AspNetCore/issues/3624
Solution is to just have x64 or x86 version of sdk/runtime/hosting.
If you have both and if you use for example x86 version of dotnet.exe it won't see x64 versions of SDK installed.
Problem usually occures when you install hosting bundle because it includes both x86 and x64. Just uninstall one you don't use.
To anyone that, like me, run into this issue on Linux and found this thread:
This problem occurs, because your .bashrc config overrides MSBuildSDKsPath environment variable with outdated value (most likely it's a leftover after dotnet package update). To solve this:
Edit ~/.bashrc
Remove the line with MSBuildSDKsPath variable initialization, e.g.
export MSBuildSDKsPath="/opt/dotnet/sdk/2.2.108/Sdks/"
If you have previously worked with C# and it somehow stopped working:
For me updating to the latest version (probably of the build tools) with the "Visual Studio Installer" solved the problem.
I started getting this error after installing Visual Studio 2022 in Windows 10, when I opened up my solution. The solution contains a mix of .NET Framework 4.8 and .NET Standard 2.0 projects, and the error was on the .NET Standard 2.0 projects. I had previously Visual Studio 2019 and 2019 Build Tools installed.
The problem was that I had both x86 and x64 of dotnet installed, and both was in my systems PATH environment variable:
C:\Program Files (x86)\dotnet
C:\Program Files\dotnet
I did the following steps to fix this error:
Uninstalled VS2019
Uninstalled VS2019 Build Tools
Removed the x86 path from the environment variable
Removed the folder "C:\Program Files (x86)\dotnet" from my computer
Restarted VS2022
I think that the important part was to remove x86 from the environment variable. The other steps was just to "clean up".
I resolve the issue by installing the package directly form the Package Manager Console:
Install-Package NETStandard.Library -Version 2.0.3
Maybe you encountered the error after installing .NET core SDK 3.0. You have to check the environment variable MSBuildSDKsPath after every install of a new SDK. It must target the SDK you use to create your project. I use VS2017 with Windows 10.
For 2.2 SDK:
C:\Program Files\dotnet\sdk\2.2.104\Sdks
For 3.0 preview :
C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks
The issue was occuring for me only when I tried to build the project with
dotnet build using VS2022 .
MsBuild on the same project was working fine.
What I did was:
restore the .net core runtime sdk - I was using 3.1 at the time.
Add both sdk paths in both Path vars, for the user and system, in that order:
Delete the MSBuildSDKsPath
P.s. I had this error while trying to run the coverlet coverage analysis
Had the same issue after I updated (snip) all VS installations on my windows machine a while ago. A restart of my PC resolved the issue.
I had this same issue, and it turned out the resolution for me was none of the above for me.
I was running the VS preview version with an older version of VS. I removed the Preview VS and then had to remove each of the environment variables by hand (i.e ANDRIOD_HOME, and .Net Maui vars, etc) and was back in business. Hope this helps someone out there who has installed VS Preview only to break the dev build environment.
Cause I had a lot of diffeculties finding the url for build tools, here it is :
https://aka.ms/vs/16/release/vs_buildtools.exe
Documenantion :
https://learn.microsoft.com/en-us/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019
I encountered the same error and to fix it I installed .NET 6.0 SDK.
https://dotnet.microsoft.com/en-us/download/visual-studio-sdks
I only had .NET 7.0 SDK installed, and for whatever reason the project I was trying to use needed .NET 6.0 SDK.
I ran into this issue after installing .NET 7 to work with gRPC. After uninstalling .NET 7 the IDE was still looking for it. I deleted the empty C:\Program Files\dotnet\sdk\7 folder. I closed an opened the project it found the lastest .NET 6 installation.

Categories