Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pack multiple assemblies with dotnet pack

Just as the question says really, how can I pack multiple projects / assemblies using dotnet pack?

Using VS2017 with new csproj files.

like image 239
Matt Whetton Avatar asked Jun 23 '17 17:06

Matt Whetton


1 Answers

Include assemblies what you need in csproj file

  <ItemGroup>
    <Content Include="bin\Release\net46\Newtonsoft.Json.dll">
      <PackagePath>lib\net46\</PackagePath>
      <Pack>true</Pack>
    </Content>
  </ItemGroup>

also if you want to include assembly from your solution you can do this in the same way, but to exclude dependency to another nuget package use PrivateAssets tag

  <ItemGroup>
    <Content Include="bin\Release\net46\My.Contracts.dll">
      <PackagePath>lib\net46\</PackagePath>
      <Pack>true</Pack>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="My.Contracts.csproj">
      <PrivateAssets>all</PrivateAssets>
    </ProjectReference>
  </ItemGroup>
like image 187
Dumitru Avatar answered Sep 24 '22 02:09

Dumitru