Packing NuGet projects compiled in release mode?

Is there some way to make a NuGet package using code compiled in release mode? Or is there some reason I should only publish (make available locally, in this case) packages compiled in debug mode?

Every time I call nuget pack from my project directory, where I have the nuspec file below, on code I have only compiled in release mode, it complains about not finding the DLL in the debug folder ( "binDebugSomeProject.dll" ). If I compile it in debug mode, those files are there and it packs them up as it should.

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>$id$</id>
        <version>$version$</version>
        <authors>$author$</authors>
        <owners>$author$</owners>
        <iconUrl>http://somewhere/project.png</iconUrl>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>$description$</description>
    </metadata>
</package>

你可以这样解决: NuGet.exe pack Foo.csproj -Prop Configuration=Release (参考)。


如果您正在使用后构建事件并且想要使用Debug或Release配置创建包,则可以像这样设置构建后事件命令行:

"<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:

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

    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    
  • In this line, replace Debug with Release .
  • Save changes.
  • 链接地址: http://www.djcxy.com/p/62272.html

    上一篇: 如何让NuGet安装/更新packages.config中的所有软件包?

    下一篇: 包装在发布模式下编译的NuGet项目?