我正在尝试使用以下 Cake 脚本:
Task("Create-NuGet-Packages")
.IsDependentOn("Build")
.WithCriteria(() =>DirectoryExists(parameters.Paths.Directories.NugetNuspecDirectory))
.Does(() =>
{
var nuspecFiles = GetFiles(parameters.Paths.Directories.NugetNuspecDirectory + "/**/*.nuspec");
EnsureDirectoryExists(parameters.Paths.Directories.NuGetPackages);
foreach(var nuspecFile in nuspecFiles)
{
// TODO: Addin the release notes
// ReleaseNotes = parameters.ReleaseNotes.Notes.ToArray(),
// Create packages.
NuGetPack(nuspecFile, new NuGetPackSettings {
Version = parameters.Version.SemVersion,
BasePath = parameters.Paths.Directories.PublishedLibraries.Combine(nuspecFile.GetFilenameWithoutExtension().ToString()),
OutputDirectory = parameters.Paths.Directories.NuGetPackages,
Symbols = false,
NoPackageAnalysis = true
});
}
});
但我不断收到同样的错误:
我已确认生成的 *.temp.nuspec
文件确实包含正确的文件,并且这些文件存在于指定位置,并且 BasePath 是正确的。
注意:我已经使用 -Verbosity Diagnostic
生成传递给 NuGet.exe 的实际命令,直接运行它也会导致相同的错误消息.因此,我认为这不是 Cake 的直接问题,而是 NuGet.exe 的问题。
最佳答案
事实证明,这是我使用的目录路径的错误。我正在尝试使用 .build\_temp\_PublishedLibraries\Cake.Twitter
。
将 .build
更改为 BuildArtifacts
立即使一切正常:
经过一些挖掘后,这似乎是 NuGet 的一个已知问题(至少对某些人来说是众所周知的):
https://twitter.com/ferventcoder/status/505048107520765952
即nuget pack 无法识别以 .
开头的任何文件或文件夹。
这个问题似乎已在 Chocolatey 中得到纠正,因此,它在那里有效。
注意:我已在此处提出此问题:https://github.com/NuGet/Home/issues/3308
关于c# - 为什么 NuGetPack 响应 "Cannot create a package that has no dependencies nor content",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38911494/