Nuget.exe pack accessing debug version after update to 1.4

Jun 22, 2011 at 12:54 PM

Hi,

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?

Thanks

James

Developer
Jun 22, 2011 at 3: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 5: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

Developer
Jun 22, 2011 at 5:13 PM

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

Developer
Jun 22, 2011 at 6: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).

Developer
Jun 22, 2011 at 6:37 PM

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

Jun 22, 2011 at 10: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?

Developer
Jun 23, 2011 at 4:08 PM

What do you mean?

Jun 23, 2011 at 4: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

Developer
Jun 23, 2011 at 4: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.

Developer
Jun 23, 2011 at 5:05 PM

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

<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Developer
Jun 23, 2011 at 5: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.

Developer
Jun 23, 2011 at 5:52 PM

Build -> Configuration Manager 

Change the Active Solution Configuration.

Developer
Jun 23, 2011 at 5: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 7: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?

Developer
Jun 30, 2011 at 7: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 8: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.

Developer
Jun 30, 2011 at 8: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 at 2: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!