aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

After upgrading to ASP.NET Core 2.1, get error that project will use 2.1.0-rc1. How to fix?

Open Tgueth opened this issue 8 years ago • 30 comments

Here is the error I receive when I build the application after upgrading to 2.1,

The project was restored using Microsoft.NETCore.App version 2.1.0, but with current settings, version 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.

The error refers to line 1 in csproj, but line 1 does not refer to rc1. How do I fix this?

Tgueth avatar Jun 13 '18 17:06 Tgueth

Thanks for contacting us, @Tgueth. Can you please share a repro project for us to investigate?

mkArtakMSFT avatar Jun 13 '18 22:06 mkArtakMSFT

@dougbu, can you please look into this after @Tgueth will share a repro? Thanks!

mkArtakMSFT avatar Jun 13 '18 22:06 mkArtakMSFT

I have similar error: csproj : error : The project was restored using Microsoft.NETCore.App version 2.1.1, but with current settings, version 2.1.0 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. csproj has <TargetFramework>netcoreapp2.1</TargetFramework> but

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
  <PackageReference Update="Microsoft.NETCore.App" Version="2.1.1" />  

Please see attached a new project, that I want to use with .Net 2.1.1 ViewBooking.zip

I have a similar problem:

Error: The project was restored using Microsoft.NETCore.App version 2.1.0, but with current settings, version 2.1.0-rc1 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.

<TargetFramework>netcoreapp2.1</TargetFramework>

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />

seriouz avatar Jun 20 '18 12:06 seriouz

I added the following lines to my .csproj files and this particular error went away

<RuntimeFrameworkVersion>2.1.1</RuntimeFrameworkVersion>
<PlatformTarget>AnyCPU</PlatformTarget>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>

Now during testing I'm getting a series of errors similar to this

[6/19/2018 5:48:54 PM Informational] ------ Run test started ------ [6/19/2018 5:49:04 PM Informational] ========== Run test finished: 255 run (0:00:10.1299802) ========== [6/19/2018 5:49:10 PM Informational] ------ Run test started ------ [6/19/2018 5:50:10 PM Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: 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: C:\Program Files\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 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]

at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources) at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)

ewmccarty avatar Jun 20 '18 14:06 ewmccarty

I solved it via adding a global.json to my Project with:

{
    "sdk": { "version": "2.1.300" }
}

seriouz avatar Jun 20 '18 14:06 seriouz

Running "dotnet --info" in the Package Manager Console yielded:

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

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-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.1.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.104 [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.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [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.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

I installed dotnet-hosting-2.1.1-win(1).exe from actually version 2.1.1 Product build: cli build 20180605-09-1764970 and it seems to have resolved the problem with tests

https://github.com/dotnet/versions/tree/7a833dddfddc27f2074b755b94234a25b9757637/build-info/dotnet/product/cli/release

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

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

Host (useful for support):
  Version: 2.1.1
  Commit:  6985b9f684

.NET Core SDKs installed:
  1.1.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.104 [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.5 [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.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

ewmccarty avatar Jun 20 '18 17:06 ewmccarty

Removing <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish> from my .csproj solved the issue for me.

bmarder avatar Jun 22 '18 13:06 bmarder

I'm getting this same error on publish as well.

granthoff1107 avatar Jun 24 '18 04:06 granthoff1107

It turns out this feature is explicitly outlines in the docs. In my case My publish was using a different runtime because I was publishing using Any CPU.

If none of the other options outline work for you the easiest way to avoid this issue is to build using the same configuration that you want to publish using and then run dotnet publish --no-restore -r win10-x64 or whatever runtime you expect to publish to

granthoff1107 avatar Jun 24 '18 21:06 granthoff1107

All, thanks very much for your thoughts in this issue.

Given the docs @granthoff1107 mentioned, are there any open questions here?

dougbu avatar Jun 26 '18 17:06 dougbu

@dougbu, As a VisualStudio user, I am working with automatically generated csproj, not with cli commands. I am not aware, do I use the --no-restore argument with dotnet publish or not. I even not sure does my project use the framework-dependent or self-contained behavior. I’ve installed the new version of SDK on my machine, and then existing ( not changed) solution start to failed with the above error.

It will be nice to have error message be more csproj specific, suggest RuntimeFrameworkVersion and global.json setting as possible fixes and include a link to the article explaining possible reasons/solutions for the error.

MNF avatar Jun 26 '18 23:06 MNF

@MNF I don’t use the Cli either that’s just a quote from the docs. I solved my issue by matching my configuration for publishing to the configuration for my build, and then everything started working.

My post was more help other find a work around, it seems like this is a known issue, and my guess is Microsoft will fix this in a few builds.

In my opinion this is still a bug, there’s no reason I should use these work arounds, considering visual studio stores your build and publish configurations, it should know how to resolve this.

granthoff1107 avatar Jun 26 '18 23:06 granthoff1107

@granthoff1107, sorry, I meant to address my comment to @dougbu

MNF avatar Jun 27 '18 11:06 MNF

Sorted changing *Profile.pbxml from:

 <TargetFramework>netcoreapp2.0</TargetFramework>

to:

 <TargetFramework>netcoreapp2.1</TargetFramework>

pikax avatar Jul 04 '18 13:07 pikax

I had this problem and adding

<PlatformTarget>AnyCPU</PlatformTarget>

to the .csproj as suggested by @ewmccarty worked. Note: didn't need the RuntimeIdentifier or RuntimeFrameworkVersion tag. Turns out it's the CPU target that causes the issue.

rob-glas avatar Jul 08 '18 20:07 rob-glas

Holy crap... removing <MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish> from my .csproj solved the issue for me too @bmarder. :)

I was getting this error:

It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set SelfContained to false.

guess what: I had the RuntimeIdentifier specified already. I was going crazy with this error...

leniel avatar Jul 10 '18 16:07 leniel

Thanks to @AliDoganKim, he's answer worked for me. Short Desc: You have to shoure exact SDK's and Runtimes installed only! not both " .net core sdk 201 & .net core sdk 202 & .net core sdk 301". It may have a conflict each other. Who knows..

StackOverflow/emre

(@MNF link edited ! tnx )

emrecavunt avatar Jul 18 '18 20:07 emrecavunt

@emrecavunt , the link in your post is not working, but the url https://stackoverflow.com/questions/51367070/net-core-2-1-2-version-settings-controller-scaffolding-sequence-contains-no is correct.

MNF avatar Jul 18 '18 22:07 MNF

@JunTaoLuo does the following error come from the Web SDK or anything else our group handles? (If not, seems we should redirect any remaining questions on this long thread to the CLI team.)

Error: The project was restored using Microsoft.NETCore.App version 2.1.0, but with current settings, version 2.1.0-rc1 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.

dougbu avatar Aug 03 '18 22:08 dougbu