Skip to content

Discussion for the Microsoft.AspNetCore.App implicit version #6430

Closed

Description

@Rick-Anderson

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.

See dotnet/aspnetcore#3292.

Activity

  1. added this to the Backlog milestone on May 16, 2018
  2. modified the milestones: Backlog, on May 16, 2018
  3. OleksandrKrutykh commented on Jun 5, 2018

    @OleksandrKrutykh

    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.

  4. Rick-Anderson commented on Jun 5, 2018

    @Rick-Anderson
    ContributorAuthor

    @JunTaoLuo please comment.

  5. JunTaoLuo commented on Jun 5, 2018

    @JunTaoLuo
    Contributor

    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/

  6. OleksandrKrutykh commented on Jun 5, 2018

    @OleksandrKrutykh

    Hello @JunTaoLuo,

    I have it installed on my workstation:

    screenshot

    I also have a lot of older SDKs installed, so that might be causing the problem...

  7. JunTaoLuo commented on Jun 5, 2018

    @JunTaoLuo
    Contributor

    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.

  8. OleksandrKrutykh commented on Jun 5, 2018

    @OleksandrKrutykh

    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
    
  9. JunTaoLuo commented on Jun 5, 2018

    @JunTaoLuo
    Contributor

    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)?

  10. OleksandrKrutykh commented on Jun 6, 2018

    @OleksandrKrutykh

    @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.

  11. ToTameALand commented on Jun 8, 2018

    @ToTameALand

    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.

  12. JunTaoLuo commented on Jun 8, 2018

    @JunTaoLuo
    Contributor

    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 ?

  13. OleksandrKrutykh commented on Jun 8, 2018

    @OleksandrKrutykh

    @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.

  14. 30 remaining items

  15. nalla commented on Jan 10, 2019

    @nalla

    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..

    https://github.com/dotnet/cli/issues/10592.

  16. natemcmaster commented on Jan 11, 2019

    @natemcmaster
    Contributor

    @nalla please use dotnet/aspnetcore#3503 for that problem. It includes workarounds in the description.

  17. stijnherreman commented on Mar 28, 2019

    @stijnherreman

    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.

  18. VictorioBerra commented on Mar 28, 2019

    @VictorioBerra

    I am wondering a similar question. @stijnherreman are you asking the same thing as this? dotnet/aspnetcore#8626 (comment)

  19. stijnherreman commented on Mar 28, 2019

    @stijnherreman

    @VictorioBerra I think that's a different issue, related to aspnet/Announcements#324.

  20. jeremyw5 commented on Mar 28, 2019

    @jeremyw5

    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.

  21. scottmcm commented on Jun 3, 2019

    @scottmcm

    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.

  22. natemcmaster commented on Jun 4, 2019

    @natemcmaster
    Contributor

    @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.

  23. scottmcm commented on Jun 4, 2019

    @scottmcm

    Thanks, @natemcmaster. I'll look forward to 3.0 then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions