Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple console app requires ASP.NET packages #1958

Closed
danmoseley opened this issue May 11, 2019 · 9 comments
Closed

Simple console app requires ASP.NET packages #1958

danmoseley opened this issue May 11, 2019 · 9 comments
Assignees
Milestone

Comments

@danmoseley
Copy link
Member

  1. Install latest master SDK
C:\d\dotnet30>dotnet --version
3.0.100-preview6-011846
  1. Create a nuget.config in this folder that only uses nuget and the dotnet feed. I also cleared my nuget cache anyway.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSources>
      <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="dotnetcore-feed" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
 </packageSources>
</configuration>
  1. Create a new console app (I did this in a subfolder so it's subject to the nuget.config)
C:\d\dotnet30\2>..\dotnet.exe new console
Getting ready...
The template "Console Application" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on C:\d\dotnet30\2\2.csproj...
  Restore completed in 109.59 ms for C:\d\dotnet30\2\2.csproj.

Restore succeeded.
  1. Publish this app
C:\d\dotnet30\2>..\dotnet.exe publish -r win-x64
Microsoft (R) Build Engine version 16.1.67-preview+g13843078ee for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

C:\d\dotnet30\2\2.csproj : error NU1102: Unable to find package Microsoft.AspNetCore.App.Runtime.win-x64 with version (= 3.0.0-preview6-19260-04)
C:\d\dotnet30\2\2.csproj : error NU1102:   - Found 24 version(s) in dotnetcore-feed [ Nearest version: 3.0.0-preview4-19121-14 ]
C:\d\dotnet30\2\2.csproj : error NU1102:   - Found 2 version(s) in nuget [ Nearest version: 3.0.0-preview5-19227-01 ]
  Restore failed in 303.74 ms for C:\d\dotnet30\2\2.csproj.

I should not need ASP.NET nor should publishing it include the ASP.NET runtime.

@danmoseley
Copy link
Member Author

danmoseley commented May 11, 2019

I notice in the generated project.assets.json:

    "frameworks": {
      "netcoreapp3.0": {
        "imports": [
          "net461"
        ],
        "assetTargetFallback": true,
        "warn": true,
        "downloadDependencies": [
          {
            "name": "Microsoft.AspNetCore.App.Runtime.win-x64",
            "version": "[3.0.0-preview6-19260-04, 3.0.0-preview6-19260-04]"
          },

But I guess that doesn't help with where it's coming from. I don't have enough context on how this works to figure that out.

@livarcocc
Copy link

@dsplaisted can you take a look?

@livarcocc livarcocc added this to the Discussion milestone May 13, 2019
@dsplaisted
Copy link
Member

This is expected. The SDK will download the runtime pack for ASP.NET Core in case the app references any packages (or other projects) that depend on it. If there isn't anything that depends on it, it will not include it in the publish output.

@danmoseley
Copy link
Member Author

cc @jkotas

I see. It is non intuitive that I need to add an ASP.NET feed, but given that in production this will be all on the same nuget feed, I guess it is not something that should matter to customers.

@jkotas
Copy link
Member

jkotas commented May 14, 2019

It will matter to customers that publish self-contained apps. They will need to download a lot more stuff than what's required...

@davidfowl
Copy link
Member

Why did this happen in the first place?

@dagood
Copy link
Member

dagood commented Aug 24, 2020

IIRC this is for this reason: dotnet/sdk#10077

We will also need to download all targeting packs for the targeted framework in case we might need to depend on them via a transitive dependency (which we won't know about until after restore has happened).

NOTE: We would also like to have a property to disable transitive framework references (which would then disable the automatic download of packages you might not need).

Targeting packs are normally installed with the .NET SDK, so you won't observe this behavior with them, but I think the same explanation applies to runtime packs, which are always resolved via NuGet.

@dsplaisted please correct me if I'm wrong.

@dsplaisted
Copy link
Member

Yes.

We could avoid these downloads, but it would required a new feature in NuGet. We've discussed it before but I couldn't find it documented anywhere, so I've filed this issue to capture it: NuGet/Home#9937

@marcpopMSFT
Copy link
Member

A way to work around this was checked in a while back. See dotnet/sdk#25358 for setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants