Skip to content

dotnet restore using RID causes "empty" project.assets.json file (netcoreapp3.0) #10312

Open
@seesharper

Description

First a little bit of background.
I am one of the collaborators over at the dotnet-script repo.

We use dotnet restore as a way of getting a list of dependencies we need to execute a script.

So we basically generate a csproj file behind the scenes that looks like this.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
</Project>

Then we do a runtime specific restore

dotnet restore -r osx-x64

This generates the project.assets.json file we need to read out the dependencies.

Compilation deps are listed in the file as

 "ref/netcoreapp2.1/Microsoft.CSharp.dll": {},
  "ref/netcoreapp2.1/Microsoft.VisualBasic.dll": {},
  "ref/netcoreapp2.1/Microsoft.Win32.Primitives.dll": {},
  "ref/netcoreapp2.1/System.AppContext.dll": {},
  and so on 

Same for runtime deps

 "runtimes/osx-x64/lib/netcoreapp2.1/Microsoft.CSharp.dll": {},
 "runtimes/osx-x64/lib/netcoreapp2.1/Microsoft.VisualBasic.dll": {},
  "runtimes/osx-x64/lib/netcoreapp2.1/Microsoft.Win32.Primitives.dll": {},
  "runtimes/osx-x64/lib/netcoreapp2.1/Microsoft.Win32.Registry.dll": {},

Basically all the deps coming from Microsoft.NetCore.App

Note: We use the LockFile class from NuGet.ProjectModel to read the file.

Okay so here is the problem we are facing.
if we change the target framework to netcoreapp3.0, the project.assets.json file no longer gets populated with these dependencies.

So given the following project file

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>
</Project>

and then dotnet restore -r osx-x64

What we see here is that all the compile deps and runtime deps are "missing" from the project.assets.json file.

{
  "version": 3,
  "targets": {
    ".NETCoreApp,Version=v3.0": {},
    ".NETCoreApp,Version=v3.0/osx-x64": {}
  },
  "libraries": {},
  "projectFileDependencyGroups": {
    ".NETCoreApp,Version=v3.0": []
  },
  "packageFolders": {
    "/Users/bernhardrichter/.nuget/packages/": {},
    "/usr/local/share/dotnet/sdk/NuGetFallbackFolder": {}
  },
  "project": {
    "version": "1.0.0",
    "restore": {
      "projectUniqueName": "/Users/bernhardrichter/GitHub/Console30/Console30.csproj",
      "projectName": "Console30",
      "projectPath": "/Users/bernhardrichter/GitHub/Console30/Console30.csproj",
      "packagesPath": "/Users/bernhardrichter/.nuget/packages/",
      "outputPath": "/Users/bernhardrichter/GitHub/Console30/obj/",
      "projectStyle": "PackageReference",
      "fallbackFolders": [
        "/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
      ],
      "configFilePaths": [
        "/Users/bernhardrichter/.nuget/NuGet/NuGet.Config"
      ],
      "originalTargetFrameworks": [
        "netcoreapp3.0"
      ],
      "sources": {
        "https://api.nuget.org/v3/index.json": {},
        "https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore-tooling/index.json": {},
        "https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore/index.json": {},
        "https://dotnetfeed.blob.core.windows.net/aspnet-entityframeworkcore/index.json": {},
        "https://dotnetfeed.blob.core.windows.net/aspnet-extensions/index.json": {},
        "https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json": {},
        "https://dotnetfeed.blob.core.windows.net/dotnet-windowsdesktop/index.json": {}
      },
      "frameworks": {
        "netcoreapp3.0": {
          "projectReferences": {}
        }
      },
      "warningProperties": {
        "warnAsError": [
          "NU1605"
        ]
      }
    },
    "frameworks": {
      "netcoreapp3.0": {
        "imports": [
          "net461"
        ],
        "assetTargetFallback": true,
        "warn": true,
        "downloadDependencies": [
          {
            "name": "Microsoft.AspNetCore.App.Runtime.osx-x64",
            "version": "[3.0.0-preview5-19227-01, 3.0.0-preview5-19227-01]"
          },
          {
            "name": "Microsoft.WindowsDesktop.App.Ref",
            "version": "[3.0.0-preview5-27626-15, 3.0.0-preview5-27626-15]"
          },
          {
            "name": "runtime.osx-x64.Microsoft.NETCore.App",
            "version": "[3.0.0-preview5-27626-15, 3.0.0-preview5-27626-15]"
          },
          {
            "name": "runtime.osx-x64.Microsoft.NETCore.DotNetHostPolicy",
            "version": "[3.0.0-preview5-27626-15, 3.0.0-preview5-27626-15]"
          },
          {
            "name": "runtime.osx-x64.Microsoft.NETCore.DotNetHostResolver",
            "version": "[3.0.0-preview5-27626-15, 3.0.0-preview5-27626-15]"
          }
        ],
        "frameworkReferences": [
          "Microsoft.NETCore.App"
        ]
      }
    },
    "runtimes": {
      "osx-x64": {
        "#import": []
      }
    }
  }
}

With target framework set to netcoreapp2.1 the project.assets.jsonfile gets populated with all the resolved deps as "expected".

Is there any way to achieve the same behaviour with target framework set to netcoreapp3.0?

We have discovered though, that if we explicitly add a package reference to Microsoft.NetCore.App [3.0.0-preview5-27626-15], things are back to "normal".

We would very much like to avoid to adding this reference explicitly as we then need to know the .Net Core runtime version.

Any input/workaround on this would be greatly appreciated.

Steps to reproduce

Create a new console app (netcoreapp3.0)

dotnet new console
dotnet restore -r osx-x64

Expected behavior

project.assets.json file to be populated with resolved runtime and compilation deps

Actual behavior

project.assets.json files contains no runtime and compilation deps.

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview5-011568
 Commit:    b487ff10aa

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.14
 OS Platform: Darwin
 RID:         osx.10.14-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.0.100-preview5-011568/

Host (useful for support):
  Version: 3.0.0-preview5-27626-15
  Commit:  61f30f5a23

.NET Core SDKs installed:
  2.1.301 [/usr/local/share/dotnet/sdk]
  2.1.402 [/usr/local/share/dotnet/sdk]
  2.1.505 [/usr/local/share/dotnet/sdk]
  2.2.100 [/usr/local/share/dotnet/sdk]
  3.0.100-preview-010184 [/usr/local/share/dotnet/sdk]
  3.0.100-preview3-010431 [/usr/local/share/dotnet/sdk]
  3.0.100-preview5-011568 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview-19075-0444 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview5-19227-01 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview-27324-5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview3-27503-5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview5-27626-15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

Activity

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

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions