Nuget.exe pack accessing debug version after update to 1.4

Jun 22, 2011 at 1:54 PM


I upgraded Nuget.exe to 1.4 via the Nuget -update command.

Since then nuget.exe pack <csproj file> is trying to pack the bin\Debug files rather than the bin\Release ones.

Anyway to specify release mode files?



Jun 22, 2011 at 4:52 PM

You could specify msbuild properties to the pack command. I'm guessing your project defaults to Debug.

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

Jun 22, 2011 at 6:08 PM

Great that command set it back to release.

Was more confused by the fact it seemed to target Release in version 1.3 and Debug in 1.4. No changes to either the nuspec or csproj on my side, just updated NuGet.exe

Jun 22, 2011 at 6:13 PM

Hmmm, that doesn't seem right. How exactly do we pick the configuration when the flag is not specified?

Jun 22, 2011 at 7:06 PM

Fowler said we used to default to Release in 1.3. It's changed to pick up the default specified in msbuild (most proj files typically default to Debug if no Configuration is specified).

Jun 22, 2011 at 7:37 PM

Good, at least there is a logical explanation for the change of behavior then.

Jun 22, 2011 at 11:02 PM

Thanks for explaining this.

Just out of interest, is there anyway to specify configuration mode in either csproj file or the nuspec file?

Jun 23, 2011 at 5:08 PM

What do you mean?

Jun 23, 2011 at 5:40 PM

I mean is there any entries I can put into the nuspec file or any setting within the Visual Studio Project which allows me to default the project to Release

Jun 23, 2011 at 5:54 PM

Is there even such thing as a 'default' configuration in VS? There is a concept of a 'current', and that doesn't go in the csproj. David, what exactly are we looking at?

But anyway, the answer is probably no. Which should not be an issue since you can specify it on the nuget command line anyway.

Jun 23, 2011 at 6:05 PM

Your proj file should have a PropertyGroup that defaults to Debug Configuration

<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Jun 23, 2011 at 6:33 PM

Ah, you're right. But I see no way of changing that from within VS, which seems crazy. Oh well, at least there is some way. Though I would still suggest explicitly passing the chosen configuration on the command line to remove any ambiguity.

Jun 23, 2011 at 6:52 PM

Build -> Configuration Manager 

Change the Active Solution Configuration.

Jun 23, 2011 at 6:57 PM

That doesn't appear to affect that entry in the csproj. Instead, that just goes in the .suo file I think.

Jun 30, 2011 at 8:14 PM

I'm glad I wasn't the only one who wanted to know how to override this behavior, but I never knew it was a change.

Since overriding this default is a bit obscure (unload project, edit project file, reload project), it seems that most packages out there are going to start showing up built in Debug mode. I always figured there was some benefit to Release mode beyond having DEBUG be undefined should your code rely on it. Should the publishing documentation be updated to include parts of this discussion or is there a reason I should prefer to publish packages built in Debug mode?

Jun 30, 2011 at 8:21 PM

No, I'd say it's better to release retail packages. I agree that with the current state of things, it's probably too easy to mistakenly release debug packages.

Jun 30, 2011 at 9:34 PM

Since I brought it up, I forked the NuGet Docs and tossed in some info about the default behavior and overriding it as a parameter or project file modification. It really just seems to draw attention to the complexity, but I'm hoping it covers it well enough. I know less than nothing about contributing to projects, but here is said fork.

Jun 30, 2011 at 9:50 PM

Thanks much! You just need to send a pull request. See these instructions. Basically you just need step 7. Well, and 8 :)

Jan 17, 2014 at 3:43 AM
pranavkm wrote:
You could specify msbuild properties to the pack command. I'm guessing your project defaults to Debug. NuGet.exe pack Foo.csproj -Prop Configuration=Release
It work, thanks!