2016-06-14 63 views
6

我试图用蛋糕脚本来创建一个NuGet包:蛋糕NuGetPack配置

var configuration = Argument("configuration", "Release"); 

var binDir = Directory("./bin") ; 
var nugetPackageDir = Directory("./artifacts"); 

var nugetFilePaths = GetFiles("./**/*.csproj").Concat(GetFiles("./**/*.nuspec")); 

var nuGetPackSettings = new NuGetPackSettings 
{ 
    BasePath = binDir + Directory(configuration), 
    OutputDirectory = nugetPackageDir 
}; 

Task("NuGetPack") 
    .Does(() => NuGetPack(nugetFilePaths, nuGetPackSettings)); 

我得到以下错误:

======================================== 
NuGetPack 
======================================== 
Executing task: NuGetPack 
Attempting to build package from 'SomeProject.csproj'. 
MSBuild auto-detection: using msbuild version '12.0' from 'C:\Program Files (x86)\MSBuild\12.0\bin'. 
Unable to find 'C:\DEV\SomeProject\bin\Debug\SomeProject.dll'. Make sure the project has been built. 
An error occured when executing task 'NuGetPack'. 
Error: NuGet: Process returned an error (exit code 1). 

它搜索大会在Debug文件夹而不是Release文件夹。 如何将NuGetPack构建配置设置为在Cake中发布?

回答

9

你需要下面的命令行参数-Prop Configuration=Release添加到nuget pack命令:

var nuGetPackSettings = new NuGetPackSettings 
{ 
    BasePath = binDir + Directory(configuration), 
    OutputDirectory = nugetPackageDir, 
    ArgumentCustomization = args => args.Append("-Prop Configuration=" + configuration) 
}; 
4

它可以通过Properties属性设置:

var nuGetPackSettings = new NuGetPackSettings 
{ 
    BasePath = binDir + Directory(configuration), 
    OutputDirectory = nugetPackageDir, 
    Properties = new Dictionary<string, string> 
    { 
    { "Configuration", configuration } 
    } 
};