Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does NuGetPack respond with "Cannot create a package that has no dependencies nor content"

I am trying to use the following Cake script:

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
        });
    }
});

But I keep getting the same error:

Error returned from NuGetPack

I have confirmed that the generated *.temp.nuspec file does indeed contain the correct files, and that the files exist within the specified location, and that the BasePath is correct.

NOTE: I have used -Verbosity Diagnostic to generate the actual command that is being passed to NuGet.exe, and running that directly also results in the same error message. As a result, I don't think that this is a problem directly with Cake, but rather with NuGet.exe.

like image 940
Gary Ewan Park Avatar asked Aug 12 '16 06:08

Gary Ewan Park


2 Answers

Turns out, this was an error with the directory paths that I was using. I was trying to use .build\_temp\_PublishedLibraries\Cake.Twitter.

Changing .build to BuildArtifacts immediately made everything work:

enter image description here

After doing a little bit of digging, this seems to be a known issue with NuGet (well at least known to some):

https://twitter.com/ferventcoder/status/505048107520765952

i.e. Any file or folder that start with a . are not recognised by nuget pack.

Seemingly this issue has been corrected in Chocolatey, and as a result, it works there.

NOTE: I have raised this as an issue here: https://github.com/NuGet/Home/issues/3308

like image 193
Gary Ewan Park Avatar answered Sep 20 '22 22:09

Gary Ewan Park


This error can also be seen if you simply specify a bad path/spec in the <file src attribute and NuGet gathers no files.

like image 33
Luke Puplett Avatar answered Sep 22 '22 22:09

Luke Puplett