Skip to content

Warn when referencing packages that target a version of .NET Core that isn't installed #501

Closed

Description

@AndrewBrianHall

The NuGet UI encourages users to upgrade NuGet packages to the newest version. This causes problems when it results users upgrading packages that result in the app no longer running. E.g. We've seen this causing problem with 2017 RC where 1.1 is not installed by VS, so when people upgrade their NuGet packages the app fails to launch.

Per conversation today, we'll fix this for .csproj tooling only

Activity

  1. added this to the 1.0 RC3 milestone on Dec 15, 2016
  2. nguerrera commented on Dec 15, 2016

    @nguerrera
    Contributor
  3. davidfowl commented on Dec 15, 2016

    @davidfowl
    Member

    IMO this should be part of the diagnostic work here #26

  4. nguerrera commented on Dec 15, 2016

    @nguerrera
    Contributor

    @Andrew-MSFT We're talking about Microsoft.NETCore.App here, right? Is it really just updating the nuget package that causes the app to fail to launch? It is supposed to work to take latest of that package so long as you do not change your TargetFramework. @dsplaisted is even in the process of baking that requirement in to the SDK.

    Retargeting to something you cannot run is a different issue than being broken by a package upgrade.

  5. nguerrera commented on Dec 15, 2016

    @nguerrera
    Contributor

    Or is this just upgrading an arbitrary package that now needs netcoreapp1.1 and not netcoreapp1.0? But that should be prevented in the UI-guided upgrade process (nuget bug if it does not), and fail restore (ditto), and #26 already covers diagnostics for failed resolution, right?

  6. davidfowl commented on Dec 15, 2016

    @davidfowl
    Member

    It's because the shared framework is a "special" package and updating the package will fail if the shared framework isn't installed no matter what the TFM is.

  7. nguerrera commented on Dec 15, 2016

    @nguerrera
    Contributor

    OK, just tested and indeed I get this when running even if I don't change my TFM:

    The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found.
      - Check application dependencies and target a framework version installed at:
          C:\Program Files\dotnet\shared\Microsoft.NETCore.App
      - The following versions are installed:
          1.0.1
      - Alternatively, install the framework version '1.1.0'.
    

    This contradicts what was discussed here: #450 (comment)

    I think this means the approach in #450 is not sound.

  8. AndrewBrianHall commented on Dec 15, 2016

    @AndrewBrianHall
    Author

    @nguerrera right, the issue that we saw with 2017 RC is people go into the NuGet UI, it says that packages updates are available and when you update it fails.

    We need feature work from NuGet to eventually avoid this problem, but that won't happen in time for 2017 RTM

  9. davidfowl commented on Dec 17, 2016

    @davidfowl
    Member

    @nguerrera it should be trivial to show a diagnostic (error) when the shared framework isn't installed. I thought we inferred the major and minor from the TFM for Microsoft.NETCore.App.

  10. nguerrera commented on Dec 17, 2016

    @nguerrera
    Contributor

    @davidfowl The inference isn't merged yet. Looks like it's trending that way on the PR, but we're bouncing back and forth on the design.

    Here's what I see:

    1. The reason nuget update and restore are happy is that package Microsoft.NETCore.App,v1.1.0 claims to be compatible with TFM netcoreapp1.0. Is the package busted?

    2. If the package is correct, then when I reference it from TFM netcoreapp1.0, it should just work and not cause the error shown above on run. If it is correct and this is not what happens, then we're interpreting it wrong in the build.

    3. If I do change my TFM to something that I can't run, then I should indeed receive a diagnostic that is easy to decipher, but we should be careful to distinguish between build-time and run-time diagnostics here. We should not introduce build errors if the build works as well as on any other machine, but we just do not have what it takes to run the output. This is not different from building a binary for ARM on an x64 machine. There's no error in building it, the error occurs when I try to run it on the same machine. The message shown above is actually a decent run-time error, but it is obscured on F5 because it only flashes on the screen for an instant. I think it is sufficient for the console, but we need a better experience in the IDE -- perhaps like how my debug options change to eliminate local machine when I switch from x86 to ARM for a UWP app.

  11. nguerrera commented on Dec 17, 2016

    @nguerrera
    Contributor

    I don't mean to stretch the analogy to ARM vs x86 too far. I mean that we should design an IDE experience of some kind that happens when I try to run: e.g. one that informs me that I don't have enough installed and guides me through installing it.

  12. davidfowl commented on Dec 17, 2016

    @davidfowl
    Member

    The reason nuget update and restore are happy is that package Microsoft.NETCore.App,v1.1.0 claims to be compatible with TFM netcoreapp1.0. Is the package busted?

    No, the package is working fine. There are extra semantics that cause it to fail. That is the package is considered a "platform" package and that name is burned into runtimeconfig.json which causes it to fail at runtime. A simplifying analogy would be that Microsoft.NETCore.App has the refs and the runtime implementations are installed with the shared framework. That's why you can't run.

    but we should be careful to distinguish between build-time and run-time diagnostics here.

    As much as I agree with that in the purest forms, I'd prefer an error diagnostic in this case because it's the 90% case, it's IDE agnostic (will work in VS for MAC and VS code) and it's easiest to implement.

    The other thing is these types of error for web projects aren't visible when running in IIS. Try the same thing in a web project and look at the experience.

  13. nguerrera commented on Dec 17, 2016

    @nguerrera
    Contributor

    No, the package is working fine. There are extra semantics that cause it to fail. That is the package is considered a "platform" package and that name is burned into runtimeconfig.json which causes it to fail at runtime.

    I see, but then I'm missing the point of the 1.1 package supporting 1.0. If it just didn't claim to support 1.0, then nobody would be able to upgrade it without updating TFM, which seems to be desirable based on my evolving understanding here.

  14. davidfowl commented on Dec 18, 2016

    @davidfowl
    Member

    I see, but then I'm missing the point of the 1.1 package supporting 1.0. If it just didn't claim to support 1.0, then nobody would be able to upgrade it without updating TFM, which seems to be desirable based on my evolving understanding here.

    Agreed, we should have made it not possible to restore but it's too late now.

  15. davidfowl commented on Dec 18, 2016

    @davidfowl
    Member

    That would have lead users to change the TFM and then it would still fail the same say on f5 though...

  16. dsplaisted commented on Dec 29, 2016

    @dsplaisted
    Member

    I see, but then I'm missing the point of the 1.1 package supporting 1.0. If it just didn't claim to support 1.0, then nobody would be able to upgrade it without updating TFM, which seems to be desirable based on my evolving understanding here.

    Agreed, we should have made it not possible to restore but it's too late now.

    @davidfowl This seems to contradict with your comment here: #450 (comment)

    Could we use the target framework version instead of the platform package version when we write the framework version to the runtimeconfig.json file?

  17. dsplaisted commented on Jan 5, 2017

    @dsplaisted
    Member

    This should be addressed with #450

  18. davidfowl commented on Jan 5, 2017

    @davidfowl
    Member

    @dsplaisted it's not though, we need to see the error when things aren't installed. What we did was make it so that it's harder to get out of sync (using the TFM), the problem still exists that you may not have the runtime installed at all. That needs to be handled.

  19. dsplaisted commented on Jan 5, 2017

    @dsplaisted
    Member

    @davidfowl We've got #458 for providing an error / diagnostic when the right shared framework isn't installed. Can we use that one and close this issue?

  20. davidfowl commented on Jan 5, 2017

    @davidfowl
    Member

    Sure

  21. added theissue type on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions