Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packing NuGet projects compiled in release mode?

Tags:

nuget

You can solve it like this:

NuGet.exe pack Foo.csproj -Prop Configuration=Release

(reference)


If you are using a post-build event and you want to create a package whether using Debug or Release configuration you can setup the post-build event commandline like so:

"<path to nuget tools>\NuGet.exe" pack "$(ProjectPath)" -Prop Configuration=$(ConfigurationName)

To have NuGet automatically use Release mode when you run nuget pack, do the following:

  1. Open your .csproj file in a text editor.
  2. Find the following line:

    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    
  3. In this line, replace Debug with Release.
  4. Save changes.

The answers here are good, but I was having a lot of problems with this for a .NET Standard project. I had a project that was only going to publish Release binaries, but it wasn't respecting my default build output path.

I added this to my CSProj which then enabled me to use the accepted answer here.

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
      <OutputPath>$(SolutionDir)bin\$(PlatformTarget)\Release</OutputPath>
</PropertyGroup>