The project was restored using Microsoft.NETCore.App version 2.1.3, but with current settings, version 2.1.3-servicing-26724-03 would be used instead - .net-core

Got this error today after upgrading VS2017 to v15.8.2 and trying to build my dotnet core project (target framework .NET Core 2.1):
Severity Code Description Project File Line Suppression State
Error NETSDK1061: The project was restored using
Microsoft.NETCore.App version 2.1.3, but with current settings,
version 2.1.3-servicing-26724-03 would be used instead. To resolve
this issue, make sure the same settings are used for restore and for
subsequent operations such as build or publish. Typically this issue
can occur if the RuntimeIdentifier property is set during build or
publish but not during restore. For more information, see
https://aka.ms/dotnet-runtime-patch-selection.
What to do?

Found out solution:
Uninstall .NET Core SDK 2.1.401, that came with vs2017 v15.8.2 and install it again using an installer from the .NET Downloads page.
Source: #joshuadavidson https://github.com/dotnet/cli/issues/9897
Also quote #peterhuene:
"It's come to my attention that VS 15.8.2 did not include the correct,
final build of the 2.1.401 SDK. We are working on resolving this
issue. In the meantime, uninstalling the 2.1.401 SDK installed by
Visual Studio and installing the SDK from the .NET Downloads site
should correct the issue."
Update, September 7th 2018:
or simply upgrade to VS2017 v15.8.3, where the problem is resolved:
"Visual Studio 2017 version 15.8.2 contained a pre-release build of
.NET Core SDK 2.1.401 that is incompatible with Visual Studio. We have
corrected this issue with Visual Studio 2017 version 15.8.3."

Related

Microsoft.NETCore.App.Host.win-x64 not found while nuget restore starting dotnetcore SDK 3.1.420

Context
After migrating to version 3.1.420 of dotnetcore SDK (installed automatically by Windows Update) we are facing the problem, that a solution failed to build (on a build server) because nuget restore is unable to restore the package Microsoft.NETCore.App.Host.win-x64.
We have local package feeds configured in nuget.config, the source nuget.org is not and must not accessed directly!
Now I get the following output:
c:\> nuget.exe restore ***.sln -NoCache -NonInteractive -ConfigFile .nuget\NuGet.config
[...]
Errors in C:\build\_work\313\s\***.csproj
NU1101: Unable to find package Microsoft.NETCore.App.Host.win-x64. No packages exist with this id in source(s): ***, ***, ***
NuGet Config files used:
C:\build\_work\313\s\.nuget\NuGet.config
Feeds used:
https://***.com/tfs/***/_packaging/A***/nuget/v3/index.json
https://***.com/tfs/***/_packaging/B***/nuget/v3/index.json
https://***.com/tfs/***/_packaging/C***/nuget/v3/index.json
Environment:
C:\build\_work\313\s>dotnet --list-sdks
3.1.420 [C:\Program Files\dotnet\sdk]
5.0.400 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
Question
Why restore process tries to fetch the nuget package while the content is already part of the SDK installed?
What I've tried?
I've analyzed the behavior of the nuget.exe using Process Monitor (Sysinternals).
I found that the folder c:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x64\3.1.25\ is accessed but not found, only the folder 3.1.26 exists after update of SDK.
Why restore process tries to access "3.1.25" while "3.1.26" is installed?
On my local machine the restore works as expected. The package is NOT available in my local NuGet cache. Here the folder c:\Program Files\dotnet\packs\Microsoft.NETCore.App.Host.win-x64\3.1.26\ is accessed as expected.
I also tried to reinstall the SDK version. No effect.
Firstly, I highly recommend avoiding nuget.exe restore. If you can, prefer dotnet restore, and otherwise msbuild -t:restore. It's unrelated to the problem you're having here, but you can avoid different types of problems by migrating.
Anyway, the .NET Core SDK 3.1.419 would have had the version 3.1.25 versions of the runtime host, whereas .NET Core SDK 3.1.420 has version 3.1.26 of the runtime hosts. Hence, when the SDK upgraded from 419 to 420, the old version of the runtime host was removed, and the new one installed.
However, as your dotnet --list-sdks output shows, you have the .NET 5 SDK installed. .NET 5 is now out of support, and so it did not receive any update in this month's Patch Tuesday. In May, the last month that the .NET 5 SDK was updated, the latest version of the .NET 3.1 hosting app package was 3.1.25, so when you restore/build an app targeting .NET Core 3.1 with the .NET 5 SDK, the SDK checks for the version of the runtime hosting package it knows about, sees it isn't available locally, and then tells NuGet to download it.
You can either use a global.json to pin that directory's dotnet commands to the .NET 3.1 SDK, or you can install the June 2022 .NET 6 SDK (6.0.301), and then both of them will know that the .NET 3.1 runtime hosting package is version 3.1.26, and therefore should not ask NuGet to download it. Well, unless you uninstall the .NET 3.1 SDK completely and use the .NET 6 SDK to build it.
I know it's confusing. The .NET marketing people chose names that doesn't aid in understanding the difference, but the .NET SDK are build tools that can build any version of .NET equal or lower version, and the .NET runtime is completely independent. As mentioned previously in this answer, you can build .NET Core 3.1 apps with the .NET 6 SDK, the .NET Core 3.1 SDK is not needed (but the runtime will be, unless you publish a "self-contained" app).

Building net5.0 solution on TeamCity agent results in "reference assemblies not found" error

I have recently upgraded our .Net Core 2.2 application to .Net 5.0. I'm now trying to upgrade our TeamCity build agent, so it can build this solution.
Installed the .Net 5.0 SDK on the build agent, and restarted the machine.
Installed the latest Community edition of Visual Studio on the build agent as well.
When I try to run a build on the agent using "dotnet msbuild", it shows this error message:
[Building CodeEngineQueryBuilder4] C:\Program Files\dotnet\sdk\5.0.202\Microsoft.Common.CurrentVersion.targets(1216,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.
More info:
RDPed onto the build agent and run "dotnet --info" on the command line, which gave me ".Net SDK Version 5.0.203"
I did find directory "C:\Program Files\dotnet\sdk\5.0.203" on the build agent, so it seems .Net 5.0 is installed.
The build agent runs Windows 8.1.
The TeamCity installation is on the latest version.
What am I missing here?
In the end, I found that I had to change the system environment variable MSBuildSdksPath
to make it point at the new .net5 Sdk directory.
In my case, I repointed it at:
C:\Program Files\dotnet\sdk\5.0.203\Sdks

Pipeline Nuget restore failing on .Net Core 3.0 Preview 8 project (NU1202)

I updated a project from netcoreapp2.2 to netcoreapp3.0 and use Preview8 SDK as well as Microsoft.EntityFrameworkCore.SqlServer, tools, and design.
I can build and run my projects locally just find (VS 2019). But when I try to deploy with Azure DevOps, the Nuget restore gives this error:
NU1202: Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview8.19405.11 is not compatible with netcoreapp3.0 (.NETCoreApp,Version=v3.0). Package Microsoft.EntityFrameworkCore.SqlServer 3.0.0-preview8.19405.11 supports: netstandard2.1 (.NETStandard,Version=v2.1)
Every reference to an EntityFrameworkCore package will result in that error.
I'm setting the .Net Core SDK in the pipeline to Preview8 via a global.json.
I have a NuGet tool installer task, bringing in the latest version, and a Nuget Restore task command running against my solution.
My problem was that I was using the Nuget Restore. Changing it to dotnet restore made the trick.
This problem is caused by an obsolete version of NuGet agent.
Use NuGet Install Tool task (a.k.a. Use NuGet) and setup the agent to the v5.x.
This is a low profile solution.
EDIT: Yay, I have enough rep to comment now.
It turns out the easier fix is to updatethe NuGet package version to the latest (5.3.0) in the "Use NuGet" task.
Not enough rep to comment on Fernando's response but it worked for me.
Edit the pipeline's Agent tasks:
add .NET Core, Display name: dotnet restore, Command: restore
set up other properties pretty much the same as the existing NuGet Restore
remove NuGet restore
Pipeline Nuget restore failing on .Net Core 3.0 Preview 8 project (NU1202)
If you are using the host agent, you should make sure you have install the netcoreapp3.0 on the agent. You could use the task Use .NET Core to install it:
Note check the option Include Preview Versions.
Note: Since netcoreapp3.0 supported by Visual Studio 2019, so, you need to make sure your agent is Hosted Windows 2019 with VS2019.
Hope this helps.

Visual studio 2017 Update 3 - The SDK 'Microsoft.NET.Sdk.Web' specified could not be found

Error:
C:\WebApp\WebApp.csproj : error : The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. C:\WebApp\WebApp.csproj
I am trying to open Dotnet core project and I am getting the above error.
I have installed the latest SDK from https://www.microsoft.com/net/core#windowscmd
I have checked the path for dotnet cmd and it works fine.
Am I missing something? Let me know if you need more information.
The target framework is set to .NET 4.5.2
I stumbled upon this issue a number of times recently. Here's a brief list of the workaround I found (one of them always worked until now):
Install the right .NET Core SDK: Either the latest version or the version required by your project.
Clean-up obsolete .NET Core versions: Go to Control Panel and uninstall previous .NET Core SDK/Runtime versions (as long as you don't use them anymore).
Create a Global.json file: Add a new global.json file to your project's root with the following content (replace the .NET Core version build with the one you want to run the project with):
{
"sdk": {
"version": "2.0.5"
}
}
Rename the SDK reference: Open your .proj file and replace <project sdk="Microsoft.NET.Sdk.web"> with <project sdk="Microsoft.NET.Sdk"> .
Add the MSBuildSDKsPath Environment Variable: The dotnet CLI sets the MSBuildSDKsPath environment variable when invoking MSBuild: however, a December 2016 patch changed the CLI behaviour so that it will respect an existing environment variable, if it has already been set: this will allow the developer to “force” the CLI to use a specific SDK.
Check your PATH: Verify that both C:\Program Files\dotnet and C:\Program Files (x86)\dotnet are in the PATH environment variable.
For additional info regarding the issue and other viable fixes check out this blog post that I wrote on this topic.
I agree with the comment on Sundeep's answer, you shouldn't have a global.json file in your project anymore.
It seems as though installing the .NET Core 2.0 SDK is causing issues with the PATH. Verify that C:\Program Files\dotnet and C:\Program Files (x86)\dotnet are in the PATH environment variable. In my case, these values were already present under System Variables so I added them to User Variables and rebooted my machine. This resolved my issue.
As suggested in the comment, I updated global.json file as shown below
{
"sdk": {
"version": "1.0.0"
}
}
Also, I had to remove the <ItemGroup> which contains wwwroot files path in .csproj file.
Reload the project and it works like a charm!
I've encountered the same problem, I just rename <project sdk="Microsoft.NET.Sdk.web"> to <project sdk="Microsoft.NET.Sdk"> on csproj
another situation:
https://stackoverflow.com/a/55529011/2971851
issue details: 2.1.6xx & 2.2.2xx version of the SDKs are only supported
on Visual Studio 2019. VS 2017 needs 2.1.5xx & 2.2.1xx versions of the
SDK.
How to fix the issue? Install 2.1.5xx version of the SDK if you are
targetting a 2.1 app Install 2.2.1xx version of the SDK if you are
targetting a 2.2 app.
and according to the official document:
Note: If you are a Visual Studio user, there are MSBuild version
requirements so use only the .NET Core SDK supported for each Visual
Studio version. If you use other development environments, we
recommend using the latest SDK release.
Do not uninstall previous SDK versions!
When I followed the 2nd step suggested in Darkseal's answer, uninstalling the previous SDK versions, it caused an "expected imports are missing" fatal error every time I opened up my project, so I needed to repair my Visual Studio, since installing the old SDK versions again kept popping up this error...
Also the other steps mentioned in that answer did not make any difference (both dotnet references were present in the environment variables and MSBuildSDKsPath was not needed for me).
Install the proper SDK version and select it in the Solution's Properties
As Jyoten mentioned I was using VS2017 x86 version and my SDKs were x64.
However, this was not the only issue, it seems there's some incompatibility with some SDK versions and VS2017. Having installed SDK v2.2.203 and v2.2.202, they would never showed up in the Target framework dropdown when I double-clicked the Properties on my project's solution (in the Solution Explorer (Ctrl+Alt+L)).
So I needed to install v2.2.105 x86 as mentioned in this answer, for it to show up in that dropdown.
Once it did, the solution that was requiring .NET Core v2.2 worked properly (did the Build normally).
I had this issue when I had to open a .Net Core 1.0.4 project in VS2017.
When I installed 1.0.4 SDK, i chose the x64 version which placed the sdk files in 'c:\Program Files\dotnet' ...
but my VS2017 was 32bit and was therefore looking for the sdk in 'c:\Program Files (x86)\dotnet'.
Once I installed the 32 bit version of the SDK it worked fine.
I was running into an issue where creating a new ASP.NET Core 2.0 project was giving me an error The SDK 'Microsoft.Net.Sdk.Web' specified could not be found, and leaving me unable to open the project in Visual Studio. The problem was the project was created in a folder that contained a global.json file, tying the SDK version to 1.0.0.
Deleting the global.json, or updating it to 2.0.0, fixed the issue. Be sure to check parent folders too - if any parent folder contains a global.json, the SDK version specified in the "closest" folder will be used.
I was getting this error in Visual Studio Code.
I was able to find the issue by setting the OmniSharp log settings in VS Code to debug. Once I did that I could see that it wasn't finding Microsoft.Build.Resources.dll.
I installed MS Build by repairing my VS 2017 Community installation. That fixed it.
uninstall and reinstall microsoft .NET core SDK.
then restart visual studio.
this works for me.
Choose the proper SDK according to your Visual Studio and Operating System. I downloaded the correct version from here https://dotnet.microsoft.com/download/visual-studio-sdks and after that .Net Core appeared in target frameworks list (there is a strict dependence between sdk version and VS version, so be careful).
I have solved this issue by,
go to this site, https://dotnet.microsoft.com/download
In that, install both .NET Core Runtime and .NET Core SDK.
After you install that, Open the Visual Studio 2017 with an administrator, Now The problem has been gone😊
I edited the .csproj file and changed netcoreapp2.2 to netcoreapp2.1 in this stanza & then I was able to get it working.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
Install the proper SDK version and go to below links
https://dotnet.microsoft.com/download/dotnet-core/thank-you/sdk-3.1.403-windows-x64-installer
https://dotnet.microsoft.com/download/dotnet-core/thank-you/runtime-desktop-3.1.9-windows-x64-installer
This worked for me:
Make sure that the .NET folder where SDKs are and Visual Studio are
in the same program files (x86) or program files.
Provide the path to the SDK in the environment variable.
If anyone else stumbles upon this issue (including future me), I had the same problem and tried literary every solution proposed here and nothing worked. Finally what fixed the issue for me was deleting NuGetFallbackFolder in C:\Program Files\dotnet\sdk.
After deleting that folder, everything just started to work magically.
I had this error when from old project (in .NET 4.7.2) I was trying to do:
var project = new Microsoft.Build.Evaluation.Project(someDotNet6ProjectPath);
The solution was to upgrade Microsoft.Build packages.

The .NET Core SDK is not installed or cannot be found under the path

When compiling .Net Core RC2 project under VS 2015 I am receiving following error
GETSDKTOOLINGINFO : error : The .NET Core SDK is not installed or
cannot be found under the path C:\Program Files\dotnet\bin. These
components are required to build and run this project.
Files do exist under that directory.
Also when I input dotnet into command line I do see it's prining proper version number and stuff.(.NET Command Line Tools (1.0.0-beta-001598)
Any idea how to resolve the issue?
Remove all older versions of core
Unistall Microsoft .NET CLI for Windows from control panel if it exists. This helped me.
After you install RC2, Make sure your control panel shows ONLY these for .Net Core
Microsoft .Net Core 1.0.0 RC2 - VS 2015 Tooling Preview 1 (1.0.20513.14)
Microsoft .Net Core 1.0.0 RC2 - SDK Preview 1 (x64) to be version 1.0.0.2702
Hope this helps.
If you install VS 2015 and VS 2017 side by side you may end up with a situation where you have:
.NET Core 2015 x86
.NET Core 2017 x64
(Take a look in Control Panel > Programs and Features)
When you try to open a VS project/solution targeting .NET Core you get the error message described in this posting.
If you search on this error you may get taken to this page:
https://github.com/aspnet/Tooling/blob/master/known-issues-vs2015.md#missing-sdk
But the solutions described there don't work (such as editing your PATH to exclude the x64 version.)
HOWEVER .. from that page, download the x86 version of .NET x86
".NET Core 1.0.1 SDK 1.0.0-preview2-003131 download links"
CLOSE any open sessions of VS. Then uninstall .NET Core 2017 x64 and then install .NET Core x86 version you just downloaded.
Your Control Panel > Programs and Features should now look like this:
Control Panel - After
What this effectively does is that now all your .NET Core is x86 rather than a mix of x86 and x64.
Reboot not required.
Repair Microsoft .Net Core 1.0.0 RC2
In case the previous answer doesn't help you because the right version of dotnet core (SDK & Tools) is already the only one installed (I was in that case):
Repair both and that should fix your problem.
For anyone getting similar messages, here is the official Issue page in the CLI repo.
Of the mentioned workarounds, one is to remove the 'DotNet CLI' entries from the installed programs.
New update: 2021 Jan Update VS Code/ VS 2019/CLI: Get/Download LATEST CORE version
here
A) first check what you have --> run dotnet --info for runtime & dotnet --list-sdks for SDK, from the command line, then B) check which ones can be un/re-installed dotnet-core-uninstall list download MS tool from here IT WILL CLEAN uninstall correctly,
Now you can re/install .Net Core make sure you close your VS Code / VS Studio, and then do your un-install/install
(Windows Skip) for Mac only add your /usr/local/share/dotnet to PATH in your ~/.bash_profile
the install from here on Microsoft
To Fix Path for CLI commands, run these below it will add it to your path:
set DOTNET_ROOT=%USERPROFILE%\dotnet
set PATH=%USERPROFILE%\dotnet;%PATH%
set DOTNET_MULTILEVEL_LOOKUP=0
Check for dotnet --list-sdks.In my case there were none.
Installing the .NET Core sdk worked for me.
If above answers not works
Try this
If you installing 64 bit SDK's, Do uninstall x86 bit SDK's from the control penal
And Try in Visual Studio
It worked from me

Resources