dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.65k stars 1.05k forks source link

The specified framework 'Microsoft.NETCore.App', version '2.1.1' was not found after the SDK is uninstalled #9522

Closed JanFredrikD closed 4 years ago

JanFredrikD commented 6 years ago

Steps to reproduce

You need to already have the Microsoft.NETCore.App 2.1.0 SDK installed with a web project with the versionless Microsoft.AspNetCore.App in the .csproj.

Install the Microsoft.NETCore.App 2.1.1 SDK and debug your project. I got it from here: https://github.com/dotnet/versions/tree/7a833dddfddc27f2074b755b94234a25b9757637/build-info/dotnet/product/cli/release

Uninstall the Microsoft.NETCore.App 2.1.1 SDK.

Debug the web project again.

Expected behavior

Should run with version 2.1.0.

Actual behavior

Getting the following error message when debugging: It was not possible to find any compatible framework version The specified framework 'Microsoft.NETCore.App', version '2.1.1' was not found. The following versions are installed: 2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

I tried with a repair on the 2.1.0 SDK, reboot, all changes are rolled back from the source control. I cannot see a reference to the 2.1.1 version anywhere. Where does it think that I should target 2.1.1 after I have uninstalled it?

Environment data

dotnet --info output: .NET Core SDK (reflecting any global.json): Version: 2.1.300 Commit: adab45bf0c

Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.300\

Host (useful for support): Version: 2.1.0 Commit: caa7b7e2ba

.NET Core SDKs installed: 1.0.0-preview1-002702 [C:\Program Files\dotnet\sdk] 1.0.0-preview2-003121 [C:\Program Files\dotnet\sdk] 1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk] 1.0.0 [C:\Program Files\dotnet\sdk] 1.0.2 [C:\Program Files\dotnet\sdk] 1.0.3 [C:\Program Files\dotnet\sdk] 1.0.4 [C:\Program Files\dotnet\sdk] 1.1.0 [C:\Program Files\dotnet\sdk] 2.0.0 [C:\Program Files\dotnet\sdk] 2.0.2 [C:\Program Files\dotnet\sdk] 2.0.3 [C:\Program Files\dotnet\sdk] 2.1.2 [C:\Program Files\dotnet\sdk] 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.100 [C:\Program Files\dotnet\sdk] 2.1.101 [C:\Program Files\dotnet\sdk] 2.1.102 [C:\Program Files\dotnet\sdk] 2.1.103 [C:\Program Files\dotnet\sdk] 2.1.104 [C:\Program Files\dotnet\sdk] 2.1.200 [C:\Program Files\dotnet\sdk] 2.1.201 [C:\Program Files\dotnet\sdk] 2.1.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 1.0.0-rc2-3002702 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

JanFredrikD commented 6 years ago

I fixed it now. The .NET Core Runtime of Microsoft.AspNetCore.App 2.1.1 was still installed, so I deleted the following folder: C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.1.1

livarcocc commented 6 years ago

Was it just the folder that was there or were all the contents for it there as well?

JanFredrikD commented 6 years ago

All the content was there as well.

JanFredrikD commented 6 years ago

It also worked if I renamed the folder to 0.1.1

sonicdivx commented 6 years ago

yeah getting the error also updating AspNetCore.All to latest. Following the link in output http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

I uninstalled / reinstalled 2.1.300 . Though my folder is is 2.1.0. Going to try rename trick @JanFredrikD mentioned

Also I used SDK

tstojecki commented 6 years ago

Ran into this problem too. I installed the latest SDK - 2.1 SDK (v2.1.300) and updated the package Microsoft.AspNetCore.App to v2.1.1

When running dotnet run, I get The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was not found. ...

The following is installed on my machine:

and under the Program Files\dotnet\shared folder I have 2.1.0 folders everywhere

dasMulli commented 6 years ago

@tstojecki how did you update the package? did the NuGet package manager offer you to update the package reference?

The idea is that you don't specify the version of the package in the project file and let the tooling choose a version for you:

<Project Sdk="Microsoft.NET.Sdk.Web">
…
<ItemGroup>
   <!--  No Version needed -->
  <PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
sonicdivx commented 6 years ago

@dasMulli That makes sense, but (and I did not create the project I am working in) I wonder if it gets assigned when create the project if not using the current releases.

tstojecki commented 6 years ago

@dasMulli Yes, the NuGet package manager suggested the update to 2.1.1.

What did it for me was installing this specific version https://github.com/dotnet/versions/tree/7a833dddfddc27f2074b755b94234a25b9757637/build-info/dotnet/product/cli/release/2.1.1

I am confused though, installing the .NET Core 2.1 SDK (v2.1.301) from https://www.microsoft.com/net/download/windows

appears to be installing 2.1.0 framework files under program files/dotnet/shared Microsoft.AspNetCore.All -- 2.1.0 Microsoft.AspNetCore.App -- 2.1.0 Microsoft.NETCore.App -- 2.1.0

which creates an issue when the microsoft.aspnetcore.app package is updated to 2.1.1.

Installing 2.1.1 build from the github link above installs the proper files under

Microsoft.AspNetCore.All -- 2.1.0 -- 2.1.1 Microsoft.AspNetCore.App -- 2.1.0 -- 2.1.1 Microsoft.NETCore.App -- 2.1.0 -- 2.1.1

So installing 2.1.301 of SDK from the official download page is not enough to run with microsoft.aspnetcore.app 2.1.1?

dasMulli commented 6 years ago

@tstojecki so https://download.microsoft.com/download/D/0/4/D04C5489-278D-4C11-9BD3-6128472A7626/dotnet-sdk-2.1.301-win-x64.exe for me installed 2.1.1 version of all shared frameworks. which exact installer did you use?

Please don't use a fixed version from NuGet as mentioned above.

@JunTaoLuo @natemcmaster is the websdk supposed to set properties to disallow the package manager to offer updates to the sharedfx packages? Maybe this should be made even stricter, possibly even emit a build warning if a package version is set by the user.

JunTaoLuo commented 6 years ago

The current implementation only sets the property to disallow package manager from offering updates when there is no explicit version set on the Microsoft.AspNetCore.App package dependency. If you specify an explicit version, we no-op all of our implicit logic. Is the proposal to add a warning when explicit versions are specified on references to the aspnet metapackages?

dasMulli commented 6 years ago

@JunTaoLuo yes that's the proposal. Opened https://github.com/aspnet/websdk/issues/369 to properly track/discuss it.

JanFredrikD commented 6 years ago

When you install the SDK for 2.1.1, it also installs the 2.1.1 runtime for both .NET Core and ASP.NET Core. When you uninstall the SDK, it does not remove the runtime. The issue is that Visual Studio does not check for the highest SDK version when debugging, it also checks for the highest runtime version. I think it would be more correct to only use for the highest SDK version, and instead give a warning that you have a higher runtime version.

JanFredrikD commented 6 years ago

I installed the 2.1.1 SDK today, but had to do a repair as the 2.1.1 folder that I had deleted earlier was not created during the regular install.

livarcocc commented 6 years ago

@JunTaoLuo any idea why the 2.1.1 runtime of asp.net would not have been removed when removing the SDK? That would have been my expectation.

dasMulli commented 6 years ago

I believe the installers will do some sort of ref-counting and the runtime installer is a sub-installer of the SDK. so if you remove a folder and the MSI it is associated with is still installed, the folder won't be recreated.

MarcusChamberlain commented 6 years ago

I'm getting the same error from a brand new project using the latest v2.1.301 from the downloads page. I eventually uninstalled the sdk and rolled back to v2.1.300 and everything is working again. Something weird is going on with the latest installer.

dasMulli commented 6 years ago

@MarcusChamberlain what exactly is the error? was it the result of a project created with dotnet new or through VS? can you upload the problematic project?

MarcusChamberlain commented 6 years ago

Project is attached. It was created through Visual Studio 15.7.4. One thing I noticed while setting this up is it's only the Docker version that seems to be breaking (for me at least) in 2.1.301. If I run the app outside of Docker in IIS Express it works fine. Maybe something going on with the docker hub images?

TestWebApp.zip

The full error is:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was not found.
- Check application dependencies and target a framework version installed at:
/usr/share/dotnet/
- Installing .NET Core prerequisites might help resolve this problem:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
- The .NET Core framework and SDK can be installed from:
https://aka.ms/dotnet-download
- The following versions are installed:
2.1.0 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
dasMulli commented 6 years ago

looks like you have an outdated version of the base image on your machine. can you do a

docker pull microsoft/dotnet:2.1-aspnetcore-runtime

and see if it pulls a newer version? then try rebuilding your image.

dasMulli commented 6 years ago

alternatively, you could explicitly change your Dockerfile to use the microsoft/dotnet:2.1.1-aspnetcore-runtime image.

Usually this isn't supposed to happen since your app would build for a .0 patch version of the runtime and the newer runtimes would light up and be used if installed on the machine / docker image. For ASP.NET Core 2.1.1, there were a few tooling related changes in the package that require to use 2.1.1 during build and thus upgrading the minimum required runtime version to 2.1.1. If all goes well, this won't be a problem for 2.1.2 and up (you'd just be left with an image with an old runtime version in your case. but that's an issue with docker builds without doing a docker pull as part of the build regardless of the asp.net core version)

MarcusChamberlain commented 6 years ago

@dasMulli : That seemed to fix it. Strange, I've never had to pull the latest images manually before. I wonder if this fixes the issue for anyone else - hopefully it does and I didn't derail the comments with something unrelated.

dasMulli commented 6 years ago

not at all.

The reason it didn't break before is likely that for 2.0. runtime updates, the project is actually built for 2.0.0 and uses any later 2.0. runtime if available on the image. And if you didn't update the 2.0. asp.net core NuGet packages manually, it would still work (since the 2.0. runtime stores contained all previous NuGet packages of the 2.0.* range). So if you never opened the NuGet package manager and updated all the deps for the asp.net core patch releases, old images still worked.

In 2.1.0+, the same is done for asp.net core as well. However, 2.1.1 is special as it contains some important changes that affect your build so the app will be built for the asp.net core 2.1.1 runtime, not for the 2.1.0 runtime as originally planned. Though if everything works out, from the next patch update forward, your app will always be built for 2.1.1 and any newer 2.1.* runtime will just be used at run-time. This change for 2.1.1 however requires that you use the latest docker image or runtime on target servers.

If anything, we may have discovered some shortcomings of the VS build tooling for docker. No idea whom to tag for this though. @livarcocc any idea?

docker build has a --pull flag to ensure that all images used during the build of a container are up to date. I don't know how this works for docker-compose or how VS handles building the containers involved. If it builds all projects' Dockerimage first and then uses compose, VS could improve here by passing along the --pull option.

livarcocc commented 6 years ago

Ok, this is now a super long issue where I believe the original issues have now been addressed. We had problems pushing the SDK bits through on release for 2.1.301 and the nuget packages were published before the SDK. This is now addressed.

As for docker, I am tagging @MichaelSimons to see if he knows exactly who to talk to in VS or if there is a repo on github that we can file an issue on.

For now, I am closing this one though.

MichaelSimons commented 6 years ago

Any Issues related to the VS Docker tooling should get logged at https://github.com/Microsoft/DockerTools/issues.

CarlosTorrecillas commented 6 years ago

Thanks for this! It made my day!! @JanFredrikD

rob-glas commented 6 years ago

I had this issues and had to remove all the old versions of aspnetcore.all and then reinstall the latest version of the .netcore sdk. The output from my project directed me http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409 here to download it.

Jan-Hettich commented 6 years ago

The error message might be misleading. I got this when the actual error was that I just had a missing NuGet package (Microsoft.EntityFrameworkCore.Design).

roxxshivamsingh commented 4 years ago

Finally I resolved this problem!! Because of 3.0 version. You need to uninstall completely with following steps: 1.go cmd and type "dotnet tool uninstall -g mlnet"

  1. Go program files and uninstall dotnet core 3.0
  2. download (if you don't have) 2.2.204 version which is capable for dotnet mlnet Thanks!!