Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude assembly from NuGet package when packing csproj?

I want to use "dotnet pack" to produce a nuget package, but I don't want to include the assembly file. My project doesn't have code, yet calling "dotnet pack" creates a package with an empty assembly in it.

How can I do this using csproj and dotnet.exe?

like image 565
natemcmaster Avatar asked Mar 17 '17 22:03

natemcmaster


1 Answers

You have two options:

  1. Use a nuspec file instead of csproj. NuGet's support for packs a csproj is not as flexible as using the nuspec directly. See https://learn.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-nuspec-package-manifest-file
  2. In your csproj file, set the property <IncludeBuildOutput>false</IncludeBuildOutput> (add to a PropertyGroup section). This instructs the "Pack" target not to add the assembly to the package. See https://learn.microsoft.com/en-us/nuget/schema/msbuild-targets for more details.
like image 194
natemcmaster Avatar answered Oct 20 '22 07:10

natemcmaster