Creating a Nuget package with Cake and packing only dlls

1.3k Views Asked by At

When I create a nuget package from the command prompt through myPath\nuget.exe pack -Prop Configuration=Release my nuget package contains the DLL and nothing else; like I want it to.

When I create a Nuget package with Cake, every file in the project folder is included.
How can I get a Cake Nuget to only include my dll? to behave like the command prompt.


In file build.cake I have

Task("Package")
    .Does(() =>{
        NuGetPack("../CompulsoryCow/CompulsoryCow.nuspec", new NuGetPackSettings{
            Id = "CompulsoryCow",
            Authors = new []{ "LosManos" }, 
            Version = "1.0.0", 
            Description = "TBD", 
            Verbosity = NuGetVerbosity.Detailed,
        }
    );
});

My CompulsoryCow.nuspec file, that works with nuget.exe pack.

<?xml version="1.0"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>$version$</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <licenseUrl>https://raw.githubusercontent.com/LosManos/CompulsoryCow/master/License.txt</licenseUrl>
    <projectUrl>https://github.com/LosManos/CompulsoryCow</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <summary>...</summary>
    <releaseNotes>...</releaseNotes>
    <copyright>LGPLv3+NoEvil.</copyright>
    <repository type="git" url="https://github.com/LosManos/CompulsoryCow" />
  </metadata>
</package>

Update:

I added BasePath to the NuGetPackSettings to point at the ..bin/release folder where I have the DLL and PDB. It packs some more files but I suppose that is well behaved.

Output:

Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'CompulsoryCow.dll'.
Added file 'CompulsoryCow.nuspec'.
Added file 'CompulsoryCow.pdb'.
Added file 'package/services/metadata/core-properties/3a1990a4516a46118d81f4bd5961a767.psmdcp'.
1

There are 1 best solutions below

0
On BEST ANSWER

I switched to use CompulsoryCow.csproj instead and then it behaves like when invoked from the command prompt. The DLL is packed but not the PDB.
On a side note it picks up Id, Authors, Version and Description from the nugetspec file; something it did not do when i used CompulsoryCow.nuspec.

Added file '[Content_Types].xml'.
Added file '_rels/.rels'.
Added file 'CompulsoryCow.nuspec'.
Added file 'lib/net40-client/CompulsoryCow.dll'.
Added file 'package/services/metadata/core-properties/c4d7ab4804fb417e8e5f9fa4d0062c74.psmdcp'.