4

I am trying to deploy to NuGet using a script. I have the following command for doing the actual deployment:

nuget pack MyProjection.csproj -Build -Properties Configuration=Release

Based the examples provided on NuGet's website, this is the correct command line. I noticed that some examples say -Prop rather than -Properties, but I don't think it matters.

However, NuGet outputs:

Attempting to build package from 'MyProject.csproj'.
Building project for target framework '.NETFramework,Version=v4.0'.
Packing files from 'C:\Users\...\MyProjection\bin\Debug'.
Using 'MyProject.nuspec' for metadata.
Successfully created package 'C:\Users\...\MyProject\MyProject.2.2.0.0.nupkg'.

Notice that it is packaging files in the Debug folder instead of the Release folder!

If I remove the -Build setting, it grabs the files from the Release like it's supposed to. The first question is: have I been publishing debug versions of my project? The second question is: how do I use these two command arguments together?

If I have to, I'll build the project using MSBuild.

4

1 回答 1

4

打包项目时,nuget 将使用当前项目设置,忽略从命令行传递的配置选项。例如,basepath 参数也是如此。

如果您将默认配置更改为发布,nuget 将使用发布位构建您的包。在 .csproj 中查找以下内容:

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

并将其更改为:

  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
于 2013-02-19T18:52:40.583 回答