c# - 为什么 NuGetPack 响应 "Cannot create a package that has no dependencies nor content"

标签 c# nuget cakebuild

我正在尝试使用以下 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
        });
    }
});

但我不断收到同样的错误:

Error returned from NuGetPack

我已确认生成的 *.temp.nuspec 文件确实包含正确的文件,并且这些文件存在于指定位置,并且 BasePath 是正确的。

注意:我已经使用 -Verbosity Diagnostic 生成传递给 NuGet.exe 的实际命令,直接运行它也会导致相同的错误消息.因此,我认为这不是 Cake 的直接问题,而是 NuGet.exe 的问题。

最佳答案

事实证明,这是我使用的目录路径的错误。我正在尝试使用 .build\_temp\_PublishedLibraries\Cake.Twitter

.build 更改为 BuildArtifacts 立即使一切正常:

enter image description here

经过一些挖掘后,这似乎是 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/

相关文章:

c# - 发布引用其他程序集的 nuget 包

visual-studio - 将数据集添加到报表时 Visual Studio 崩溃,无法加载文件或程序集

c# - .NET Framework (4.8) 的 Cake runner 不获取环境变量

c# - 来自多个线程的安慰 session SendRequest() 正在阻塞

c# - 使用 Entity Framework 时为 Select() 创建通用选择器

c# - 来自sql查询执行 Entity Framework 的匿名类型结果

c# - String.Format 和垃圾回收

visual-studio-2017 - Visual Studio 2017 : how to include NuGet packages in solution folder

c# - 蛋糕构建 : access original command line arguments string?

c# - 将string []从批处理文件(包含双引号“)传递到powershell脚本