Dependent .deps.json file not published when a package with PrivateAssets=all is included
See original GitHub issueScenario: Project A uses Project B via ProjectReference Project B includes package C via PackageReference (in this case, NSwag.MSBUILD v13.17.0) PackageReference (automatically added like that using the nuget package manager) is added in the following manner:
<PackageReference Include="NSwag.MSBuild" Version="13.17.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Both project A & Project B are console applications, .net6
Build area: Only Project A is built using the following command:
dotnet publish -c Release
Expected result:
- Both projects A & B will be sent to output directory, and both files should arrive:
- ProjectA.deps.json
- ProjectB.deps.json
- ProjectA.runtimeconfig.json
- ProjectB.runtimeconfig.json
Actual result:
- Both projects A & B are sent to output directory
- ProjectA.deps.json
- ProjectB.deps.json <-- file missing
- ProjectA.runtimeconfig.json
- ProjectB.runtimeconfig.json
Workaround: Remove PrivateAssets=all e.g.
<PackageReference Include="NSwag.MSBuild" Version="13.17.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
I’m attaching 2 verbose publishes:
- PrivateAsset = all
- PrivateAsset removed
Project A = Press.Host.BackupAndRestoreDev Project B = Press.Host.BackupAndRestore
I tried to find differences, this is what I presume is the issue:
6.706 2:9>Target "_ComputeUseBuildDependencyFile: (TargetId:407)" in file "C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets" from project "c:\WorkSpaces\OCB3\pc\Src\Press\Host\BackupAndRestore\Press.Host.BackupAndRestore.csproj" (target "AddDepsJsonAndRuntimeConfigToPublishItemsForReferencingProjects" depends on it):
Set Property: _UseBuildDependencyFile=true
14:40:56.706 2:9>Done building target "_ComputeUseBuildDependencyFile" in project "Press.Host.BackupAndRestore.csproj".: (TargetId:407)
14:40:56.706 2:9>Target "AddDepsJsonAndRuntimeConfigToPublishItemsForReferencingProjects: (TargetId:408)" in file "C:\Program Files\dotnet\sdk\7.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets" from project "c:\WorkSpaces\OCB3\pc\Src\Press\Host\BackupAndRestore\Press.Host.BackupAndRestore.csproj" (target **"GetCopyToPublishDirectoryItems" depends on it):
Added Item(s):
AllPublishItemsFullPathWithTargetPath=
c:\WorkSpaces\OCB3\Press\Press.Host.BackupAndRestore.deps.json
CopyToPublishDirectory=PreserveNewest
TargetPath=Press.Host.BackupAndRestore.deps.json**
Doesn’t exists with PrivateAssets = all is written.
Issue Analytics
- State:
- Created 8 months ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
NET CLI tool contains deps.json with development ...
The deps. json contains all dev dependencies and does not make sense for NET tools. The solution was to disable the generation of...
Read more >PackageReference in project files - NuGet
When developmentDependency is set to true in a .nuspec file, this marks a package as a development-only dependency, which prevents the package ......
Read more >Deep-dive into .NET Core primitives: deps.json ...
The deps.json file is a dependencies manifest. It can be used to configure dynamic linking to assemblies that come from packages. As mentioned ......
Read more >How to generate runtimeconfig.json\deps. ...
Net Core 2.1 library. It has a runnable dependency - .Net Gateway, which I need to start first. However dotnet publish generates .runtimeconfig....
Read more >Problem with dependencies after publishing winforms ...
Data.SqlClient, Version=4.5.0.0" occurs because the .deps.json file is included by default . If I manually delete the .deps.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As a workaround we’re using the following target which can be used in a csproj or Directory.Build.targets file. The target copies all deps.json files from the build output (where they are deployed to) the publish output.
We’re also running into this problem when trying to combine publish output from multiple projects. Since we’re using Nerdbank.GitVersioning having PrivateAssets=all as a PackageReference property is crucial since some projects are also provided as nuget-packages.
@baronfel is the minimal repo sufficient to triage this issue? While not a lot of people will have this kind of setup with one executable referencing another, this is hopefully something to easily isolate and fix.