question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"donet pack" is not including project references

See original GitHub issue

Steps to reproduce

git clone https://github.com/ivanz/dotnet-pack-repro.git
dotnet restore
dotnet build src\MainProject
dotnet pack src\MainProject

Expected behavior

DependencyProject.dll should be included in the .nupkg for the net46 framework:

{
    "version": "0.10.0-unstable-*",
    "frameworks": {
        "net46": {
            "dependencies": {
                "DependencyProject": {
                    "target": "project"
                }
            }
        },
        "netstandard1.5": {
            "dependencies": {
                "NETStandard.Library": "1.6.0"
            }
        }
    }
}

Actual behavior

DependencyProject.dll is not included at all in the .nupkg

Environment data

dotnet --info output:

> dotnet --info                                    
.NET Command Line Tools (1.0.0-preview2-003121)    

Product Information:                               
 Version:            1.0.0-preview2-003121         
 Commit SHA-1 hash:  1e9d529bc5                    

Runtime Environment:                               
 OS Name:     Windows                              
 OS Version:  10.0.10586                           
 OS Platform: Windows                              
 RID:         win10-x64                                                               

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:9
  • Comments:57 (8 by maintainers)

github_iconTop GitHub Comments

52reactions
blackdwarfcommented, Jul 28, 2016

@ivanz you need to dotnet pack each dependency separately. This is by design.

48reactions
dasMullicommented, Sep 30, 2017

There actually is a ““simpler”” solution at the moment, involving adding and hooking up a custom target (tested on latest released bits):

<Project>
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeP2PAssets</TargetsForTfmSpecificBuildOutput>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\testprivatelib\testprivatelib.csproj" PrivateAssets="All" />
  </ItemGroup>

  <Target Name="IncludeP2PAssets">
    <ItemGroup>
      <BuildOutputInPackage Include="$(OutputPath)\testprivatelib.dll" />
    </ItemGroup>
  </Target>
</Project>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet pack - include referenced projects
When running dotnet pack and having references to other projects, the following nuspec ... dotnet pack is not including project references.
Read more >
"donet pack" is not including project references · Issue #6688
I build the package with nuget and the nupkg file contained all 3 DLLs. The same behavior is not happening with dotnet pack....
Read more >
dotnet pack command - .NET CLI
The dotnet pack command builds the project and creates NuGet packages. ... references to other projects, the other projects aren't included ...
Read more >
asp.net core - Include all dependencies using dotnet pack
Is there any way to force dotnet pack to include all referenced assemblies (all dependencies in project.json)?. I believe this is related: https ......
Read more >
Include both Nuget Package References *and* project ...
The official stance (as I understood it) is that the project references won't be included as they should be their own packages. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found