Leave comments/questions about the Microsoft.AspNetCore.App implicit version.
Copy from @natemcmaster
After reviewing customer feedback and lots of design discussion, we think the implicit package version has created more confusion than help. We are planning to change course and go back to recommending using the Version attribute on the PackageReference to Microsoft.AspNetCore.App/All.
I've changed the PackageReferences in my projects from Microsoft.AspNetCore.All to Microsoft.AspNetCore.App (without version number) as was suggested by the ASP.NET Core 2.0 to 2.1 migration guide. After that I got a bunch of build warnings like this:
_Warning NU1604: Project dependency Microsoft.AspNetCore.App does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results._
_Warning NU1602: [Project Name] does not provide an inclusive lower bound for dependency Microsoft.AspNetCore.App. An approximate best match of Microsoft.AspNetCore.App 2.1.0 was resolved._
The Microsoft.AspNetCore.App description here contains the following phrase: "The Microsoft.AspNetCore.App metapackage is not a traditional package that is updated from NuGet." If it's not a normal NuGet package, I would expect that I should not be getting NuGet warnings for it. Getting build warnings when everything is actually fine is annoying and creates a risk that after some time I'll stop paying attention to build warnings at all and miss some "genuine" warning.
I don't think NU1602 and NU1604 should be suppressed at the project level, as these warnings make sense for "normal" NuGet packages. I tried to disable these warnings for the PackageReferences for Microsoft.AspNetCore.App using the instructions from here:
<PackageReference Include="Microsoft.AspNetCore.App">
<NoWarn>NU1602,NU1604</NoWarn>
</PackageReference>
I got fewer build warnings, but some projects still reported them. These projects themselves did not contain PackageReferences for Microsoft.AspNetCore.App, but they referenced other projects that did. To suppress warnings for these projects, I had to add PackageReferences for Microsoft.AspNetCore.App to their .csproj files. Then I was able to build the solution without warnings.
If it's relevant - I'm using Visual Studio 2017 Community Edition, version 15.7.3
My question is - is there a simpler way to suppress build warnings for Microsoft.AspNetCore.App package? It would be also good to update documentation for this metapackage and include an instruction of how to suppress them.
@JunTaoLuo please comment.
The warnings you are getting suggests that you are using the 2.0 SDK which doesn't contain the logic that sets the implicit versions for Microsoft.AspNetCore.App. Do you have the latest 2.1 SDK (2.1.300) installed? See: https://www.microsoft.com/net/download/
Hello @JunTaoLuo,
I have it installed on my workstation:
I also have a lot of older SDKs installed, so that might be causing the problem...
Hmm then I'm curious why it's not working. What does dotnet --info
say? I'm not sure installing previous SDKs will resolve the issue but it may help.
Here's the output of 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.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
1.0.0-preview2-1-003177 [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.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.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.0 [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
Hmm I'm unable to reproduce the issue locally, but I also don't have many older SDKs installed so that may be the problem. Are you able to reproduce the issue on the command line with dotnet restore
? If so, can you collect the msbuild binlog and share it with me so I can debug (run dotnet restore /bl
and attach the msbuild.binlog)?
@JunTaoLuo, thank you for taking the time to look into that.
Yes, I'm getting the same warnings when running dotnet restore
through command line
Here's the msbuild binlog for one of the projects: msbuild.zip. For your information - not all projects in my solution that reference Microsoft.AspNetCore.App produce NuGet warnings.
For me following change in csproj project file helped: <Project Sdk="Microsoft.NET.Sdk">
-> <Project Sdk="Microsoft.NET.Sdk.Web">
My case was a class library project that was converted from 2.0 to 2.1 and had a following reference:
<PackageReference Include="Microsoft.AspNetCore.App" />
Using Visual Studio 15.7.3 and 2.1.300 SDK.
Sorry for the slow response, but as @ToTameALand mentioned the problem here is that the SDK must be set to Microsoft.NET.Sdk.Web
for the implicit version to be set correctly. The sample at https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.1 shows this but maybe we can make this more explicit @Rick-Anderson ?
@JunTaoLuo, @ToTameALand, thank you for looking into this! You are right, all projects in my solution that produced the NuGet build warnings indeed use Microsoft.NET.Sdk
instead of Microsoft.NET.Sdk.Web
. I assume that they use Microsoft.NET.Sdk
because they are class libraries, not ASP.NET Core projects. It looks like I should not have added references to Microsoft.AspNetCore.App there in the first place...
I've removed the references to Microsoft.AspNetCore.App from my class libraries, actual ASP.NET Core projects still reference Microsoft.AspNetCore.App. I don't get any warnings when building my solution now.
As regards https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.1, a warning like "Do not add a reference to Microsoft.AspNetCore.App to your class library, it won't work properly" could be included there, so that another developer wouldn't make the same mistake that I did.
Same issue here, the comment https://github.com/aspnet/Docs/issues/6430#issuecomment-394864697
help me remove warning
When I install current SDK (2.1.301) and publish default web applicatation to azure with implicit version, I get:
App Service Development Console in Azure Portal:
> dotnet --info
D:\home\site\wwwroot
.NET Core SDK (reflecting any global.json):
Version: 2.1.300
Commit: 32f29b6eb9
> dotnet webapplication1.dll
D:\home\site\wwwroot
It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was not found.
If it is recommended to use implicit version, then WTF?
It looks like azure doesn't have the 2.1.301 SDK or the 2.1.1 runtime installed yet. @davidebbo do you know when the new bits will be available?
Previous comment was 3 days ago, and deployment completed Friday morning PST. My guess is that at the time @Liero tried it wasn't there yet, but got there shortly after. Please try again.
@JunTaoLuo: my point is, that following recommended practices results in very poor developer experience. Do you think that application startup failure caused just by installing latest SDK locally that differs only in patch version is predictable and expected behavior? If no, then do something about it.
@Liero In general we don't expect to increment the implicit version of the Microsoft.AspNetCore.App metapackage during patches, as described in the documentation: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.1. However, during this release, we realized there were some issues with our version ranges that could lead to more warnings and errors in future patches so we needed to modify the metapackage and increment the implicit version used by apps targeting netcoreapp2.1
. We hope we don't have to do this in the future so this should not happen again.
A key issue here is that if we compile with warnings as errors (as we do) this will break the build, unless we explicitly add NoWarn for these errors. I think it is problematic to force a NoWarn whenever this dependency is referenced for customers that want to treat warnings as errors.
@iancooper what kind of warnings are you seeing? The reason we updated the base implicit version this release was to avoid such warnings so I'd be interested to see why it didn't work for you.
I am using Razor pages and seeing this warning. How do I fix the issue? Here is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App">
<NoWarn>NU1604</NoWarn>
</PackageReference>
</ItemGroup>
</Project>
@mrlife <Project Sdk="Microsoft.NET.Sdk.Web">
The implicit version gave me build errors in VSTS, although I am using SDK 2.1.301 there (as I do locally). I reference the Microsoft.Net.Sdk.Web and updated the other necessary NuGets for my project to 2.1.1 but in VSTS the build fails with NU1107 (version conflict), see https://github.com/aspnet/Home/issues/3250
After reviewing customer feedback and lots of design discussion, we think the implicit package version has created more confusion than help. We are planning to change course and go back to recommending using the Version attribute on the PackageReference to Microsoft.AspNetCore.App/All.
I am struggling with this right now with a ton of these errors:
If I pin my App version at 2.1.4 I have no issues. I do not understand these errors, my test project never references Microsoft.AspNetCore.Authentication 2.0.3.0
my parent project never references Microsoft.AspNetCore.Authentication 2.1.1.0
. And Icant even find any transitive dependencies that reference those numbers. So what is going on here? Did we decide that everyone should start pinning versions? I may have misread but the linked aspnet issue says "[Nate: July 9]: this was not implemented, and we are not planning to implement right now." so are we NOT deciding to stop generating templates using an implicit .App version?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>MyIdentityServer.UnitTests</RootNamespace>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MyIdentityServer\MyIdentityServer.csproj" />
</ItemGroup>
</Project>
..\..\src\MyIdentityServer\MyIdentityServer.csproj
)<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentSpace.Saml2.Licensed" Version="2.0.6" />
<PackageReference Include="IdentityServer4" Version="2.2.0" />
<PackageReference Include="IdentityServer4.EntityFramework" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.4" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="CustomDataProtection" Version="2.0.0" />
</ItemGroup>
</Project>
@VictorioBerra Try specifying an explicit version for AspNetCore.App (e.g. 2.1.3) and set the RuntimeFrameworkVersion to the same version (e.g. below TargetFramework). For console or .Net Standard library also specify the same RuntimeFrameworkVersion. That way you will have all projects running with the same Core SDK and packages.
@VictorioBerra This is the same issue as https://github.com/aspnet/Mvc/issues/7710. The solution is to add a versionless reference to Microsoft.AspNetCore.App: <PackageReference Include="Microsoft.AspNetCore.App" />
to your test project and change the sdk from Microsoft.NET.Sdk
to Microsoft.NET.Sdk.Web
@JunTaoLuo Thanks! so in 2.2 or 3.0 is this supposed to be resolved without having to add App
and Web
to a NON-web test project? Just seems ugly/hacky.
@zuckerthoben I hope I can avoid locking runtime versions with RuntimeFrameworkVersion. Something I liked about the All
metapackage was that when i upgraded that, I knew I had all the latest fixes/features. And if my app didn't run, it was obvious I was missing that specific runtime and i would install it and be on my way. In my orig post I said if i set App to 2.1.4 explicitly, my problem goes away and everything works just fine.
In short, upgrading using NuGet was just easier. Now I have more to worry about when updating. But i guess if I use RuntimeFrameworkVersion
and I dont have the runtime I get a way better error.
@JuanMejiaVelez Actually, this did not solve my issue. I get the same errors if I change my test project to .Web and add a versionless app reference.
@VictorioBerra is it possible for you to provide me with a repro so I can take a deeper look into what may be the issue? Otherwise I can try to create a similar project setup to the one you described when I get a chance to see if I run into the same error.
I will try to repro. I am actually getting inconsistent behavior now that I have been flipping everything around with versions/web. I can't even get my orig errors to come back.
@JunTaoLuo I was able to repro! https://github.com/VictorioBerra/aspnet-Docs-issues-6430
git clone https://github.com/VictorioBerra/aspnet-Docs-issues-6430.git
Essentially I created new apps with dotnet new mvc/xunit
and then I added all the packages I am using, and I also picked something random from Microsoft.AspNetCore.Authentication to use in my HomeController.
Now when I open the solution I get the same error:
If you could let me know the solution i would really appreciate it.
Visual Studio Enterprise 15.8.2
dotnet info
U:\>dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.401
Commit: 91b1c13032
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.401\
Host (useful for support):
Version: 2.1.3
Commit: 124038c13e
.NET Core SDKs installed:
1.0.0-preview2-003121 [C:\Program Files\dotnet\sdk]
1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
1.0.0-preview2-1-003177 [C:\Program Files\dotnet\sdk]
1.0.3 [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.101 [C:\Program Files\dotnet\sdk]
2.1.102 [C:\Program Files\dotnet\sdk]
2.1.103 [C:\Program Files\dotnet\sdk]
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.201 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.301 [C:\Program Files\dotnet\sdk]
2.1.302 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [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.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.3 [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.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.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.0 [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.0.9 [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]
Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
U:\>
I was able to build the Sample test project by applying the fix I mentioned in the comment above: https://github.com/VictorioBerra/aspnet-Docs-issues-6430/pull/1. Let me know if this works for you.
Replying here to keep the discussion in one place:
@JunTaoLuo this seems to work just fine. Although I really do dislike the idea of having to target a web Sdk via a test project. What will be the approach in 2.2 or 2.3? I assume this is not a permanent workaround?
@natemcmaster has more up to date information on this but I think it's the same for 2.2. However for the release after that, it will be reworked.
@JunTaoLuo I noticed a new problem related to all this I think. If you run this following command in the fixed version of the PR you gave me you get the following error:
dotnet ef migrations list
me@DESKTOP MINGW64 /c/Users/me/Desktop/temp/corebug/src/SampleMVC (JunTa oLuo-johluo/fix)
$ dotnet ef migrations list
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor..ctor(Object reportHandler, IDictionary args)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String dataDirectory, String rootNamespace, String language)
at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor()
at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsListCommand.Execute()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Exception has been thrown by the target of an invocation.
If you lock SampleMVC.csproj Microsoft.AspNetCore.App
to 2.1.4 you do not get the error.
Updating all NuGets fixed this issue somehow.
FYI, there's currently ongoing work with how references to Microsoft.AspNetCore.App should work, see https://github.com/dotnet/sdk/pull/2501.
And update on my previous comment https://github.com/aspnet/Docs/issues/6430#issuecomment-403296211 in which I said
After reviewing customer feedback and lots of design discussion, we think the implicit package version has created more confusion than help. We are planning to change course and go back to recommending using the Version attribute on the PackageReference to Microsoft.AspNetCore.App/All.
Part of this has changed. We still believe the implicit package version is confusing, but after testing and experimenting with alternatives, we do not have a solution for 2.1 or 2.2 that we feel is significantly better. We are planning to change course in 3.0 and rework how this all works, but that is pretty far away.
Therefore, our recommendation for now is that users reference Microsoft.AspNetCore.App like this:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
We have made a few changes to the 2.2 SDK to make this work better for test projects, and will continue to improve our docs and guidance for how to deal with the issues with this design. Again, we hope to fix many of these issues in 3.0 with a refactoring of the way shared frameworks are referenced.
@natemcmaster Thanks a lot for keeping us up to date. Looking forward to 2.2 and removing the .Web SDK from my test projects.
When I use implicit version, I get a TargetInvocationException
when tryting to _run_ (not build) netcore2.1
.
.NET Core SDK (reflecting any global.json):
Version: 2.2.102
Commit: 96ff75a873
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.102\
Host (useful for support):
Version: 2.2.1
Commit: 878dd11e62
.NET Core SDKs installed:
1.1.8 [C:\Program Files\dotnet\sdk]
1.1.9 [C:\Program Files\dotnet\sdk]
1.1.10 [C:\Program Files\dotnet\sdk]
1.1.11 [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.202 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.302 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.2.102 [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.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.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.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.10 [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.0.9 [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.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
The exception is the following:
[2019-01-10 16:43:15] [1] [Fatal] Application startup exception
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Connections.Abstractions, Version=2.1.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance[T]()
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
at Microsoft.Extensions.Options.OptionsManager`1.Get(String name)
at Microsoft.Extensions.Options.OptionsManager`1.get_Value()
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.CreateServiceContext(IOptions`1 options, ILoggerFactory loggerFactory)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer..ctor(IOptions`1 options, ITransportFactory transportFactory, ILoggerFactory loggerFactory)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitSingleton(SingletonCallSite singletonCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(IServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureServer()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
Changing implicit to explicit 2.1.5
helps...
I created a new issue for this because it seems to be specific to having a reference to signalr..
@nalla please use https://github.com/aspnet/AspNetCore/issues/3503 for that problem. It includes workarounds in the description.
I have a netstandard2.0 class library that references some AspNetCore packages. Do I target reference the 2.2.0 version of these packages, or 2.2.1/2.2.2 where available?
I've read the metapackage docs, this issue and the issue referenced in the OP, but I couldn't find clear guidance on this.
I am wondering a similar question. @stijnherreman are you asking the same thing as this? https://github.com/aspnet/AspNetCore/issues/8626#issuecomment-474470270
@VictorioBerra I think that's a different issue, related to https://github.com/aspnet/Announcements/issues/324.
I have a simple netcoreapp2.1 framework dependent Web API application that contains an implicit reference to the Microsoft.AspNetCore.App package. And, I have specified a RuntimeFrameworkVersion to indicate that the application must use a minimum runtime patch version; in this case version 2.1.9.
I am trying to test the behavior when only runtime patch version 2.1.8 is installed. I am expecting an error to occur as described in the following document:
https://docs.microsoft.com/en-us/dotnet/core/versions/selection
The application runs without error and upon inspection, the dotnet.exe process is using runtime patch version 2.1.8. This is not desirable.
Without doing a self-contained deployment, how can I force the Web API application to use a minimum runtime patch version and fail if the required runtime is not installed?
I think I am missing some key fundamental. Roll-forward behavior is acceptable, but roll-backward behavior is not.
I definitely find the implicit version confusing, because I want to be able to change a version on the metapackage for things like https://github.com/aspnet/Announcements/issues/239 -- I would expect new versions of packages all the way up to Microsoft.AspNetCore.App to be published such that they no longer accept the insecure transitive dependency so that I don't need to add new dependencies on things I get from the metapackage just to avoid insecure packages.
@scottmcm your feedback is consistent with what many others have said about this design. This feedback was part of the motivation for refactoring the way Microsoft.AspNetCore.App works in 3.0. One of the major changes here is that Microsoft.AspNetCore.App will no longer be a NuGet package at all, so you won't have to worry about metapackage versions and transitive dependencies and their related problems.
Thanks, @natemcmaster. I'll look forward to 3.0 then.
Most helpful comment
I've changed the PackageReferences in my projects from Microsoft.AspNetCore.All to Microsoft.AspNetCore.App (without version number) as was suggested by the ASP.NET Core 2.0 to 2.1 migration guide. After that I got a bunch of build warnings like this:
_Warning NU1604: Project dependency Microsoft.AspNetCore.App does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results._
_Warning NU1602: [Project Name] does not provide an inclusive lower bound for dependency Microsoft.AspNetCore.App. An approximate best match of Microsoft.AspNetCore.App 2.1.0 was resolved._
The Microsoft.AspNetCore.App description here contains the following phrase: "The Microsoft.AspNetCore.App metapackage is not a traditional package that is updated from NuGet." If it's not a normal NuGet package, I would expect that I should not be getting NuGet warnings for it. Getting build warnings when everything is actually fine is annoying and creates a risk that after some time I'll stop paying attention to build warnings at all and miss some "genuine" warning.
I don't think NU1602 and NU1604 should be suppressed at the project level, as these warnings make sense for "normal" NuGet packages. I tried to disable these warnings for the PackageReferences for Microsoft.AspNetCore.App using the instructions from here:
I got fewer build warnings, but some projects still reported them. These projects themselves did not contain PackageReferences for Microsoft.AspNetCore.App, but they referenced other projects that did. To suppress warnings for these projects, I had to add PackageReferences for Microsoft.AspNetCore.App to their .csproj files. Then I was able to build the solution without warnings.
If it's relevant - I'm using Visual Studio 2017 Community Edition, version 15.7.3
My question is - is there a simpler way to suppress build warnings for Microsoft.AspNetCore.App package? It would be also good to update documentation for this metapackage and include an instruction of how to suppress them.