You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Discussion for the Microsoft.AspNetCore.App implicit version #6430
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:
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.
Reacted by Oleg Shevchenko, Tony Ngo, Juliano Pereira Lima, nesty, Mauro Lavigna, Kristian Thy, drauch, Johnny Oshika and Kelvin Ferreira
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" />
@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.
[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..
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 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:
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 aspnet/Announcements#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.
Activity
OleksandrKrutykh commentedon Jun 5, 2018
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.
Rick-Anderson commentedon Jun 5, 2018
@JunTaoLuo please comment.
JunTaoLuo commentedon Jun 5, 2018
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/
OleksandrKrutykh commentedon Jun 5, 2018
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...
JunTaoLuo commentedon Jun 5, 2018
Hmm then I'm curious why it's not working. What does
dotnet --infosay? I'm not sure installing previous SDKs will resolve the issue but it may help.OleksandrKrutykh commentedon Jun 5, 2018
Here's the output of
dotnet --info:JunTaoLuo commentedon Jun 5, 2018
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 (rundotnet restore /bland attach the msbuild.binlog)?OleksandrKrutykh commentedon Jun 6, 2018
@JunTaoLuo, thank you for taking the time to look into that.
Yes, I'm getting the same warnings when running
dotnet restorethrough command lineHere'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.
ToTameALand commentedon Jun 8, 2018
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.
JunTaoLuo commentedon Jun 8, 2018
Sorry for the slow response, but as @ToTameALand mentioned the problem here is that the SDK must be set to
Microsoft.NET.Sdk.Webfor 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 ?OleksandrKrutykh commentedon Jun 8, 2018
@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.Sdkinstead ofMicrosoft.NET.Sdk.Web. I assume that they useMicrosoft.NET.Sdkbecause 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.
30 remaining items
Ignore missing version for package Microsoft.AspNetCore.App
nalla commentedon Jan 10, 2019
When I use implicit version, I get a
TargetInvocationExceptionwhen tryting to run (not build)netcore2.1.The exception is the following:
Changing implicit to explicit
2.1.5helps...I created a new issue for this because it seems to be specific to having a reference to signalr..
https://github.com/dotnet/cli/issues/10592.
natemcmaster commentedon Jan 11, 2019
@nalla please use dotnet/aspnetcore#3503 for that problem. It includes workarounds in the description.
stijnherreman commentedon Mar 28, 2019
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.
VictorioBerra commentedon Mar 28, 2019
I am wondering a similar question. @stijnherreman are you asking the same thing as this? dotnet/aspnetcore#8626 (comment)
stijnherreman commentedon Mar 28, 2019
@VictorioBerra I think that's a different issue, related to aspnet/Announcements#324.
jeremyw5 commentedon Mar 28, 2019
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.
scottmcm commentedon Jun 3, 2019
I definitely find the implicit version confusing, because I want to be able to change a version on the metapackage for things like aspnet/Announcements#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.
natemcmaster commentedon Jun 4, 2019
@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.
scottmcm commentedon Jun 4, 2019
Thanks, @natemcmaster. I'll look forward to 3.0 then.