1

I am trying to create a basic NuGet package programmatically using Nuget.core API.

Firstly I populate Metadata and Files field of NuSpec manifest file:

Manifest nuspec = new Manifest(); //creating a nuspec

ManifestMetadata metaDataLocal = new ManifestMetadata()
{
    Authors = "mauvo",
    Version = "1.0.0.0",
    Id = "myPackageIdentifier",
    Description = "A description",
};

nuspec.Metadata = metaDataLocal; //populating nuspec's metadata

ManifestFile mf = new ManifestFile();
mf.Source = "bin\\Debug\\DX11VideoRenderer.dll";
mf.Target = "lib";

List<ManifestFile> listManifestFile = new List<ManifestFile>();

listManifestFile.Add(mf);
nuspec.Files = listManifestFile; //populating nuspec's Files field

Then I use package builder class to create the package and save it to the debug folder of my project:

PackageBuilder builder = new PackageBuilder() 
{
    Id = "1",
    Description = "Some test package"
};

builder.Populate(nuspec.Metadata);

foreach (ManifestFile value in nuspec.Files)
{
    builder.PopulateFiles(value.Target, nuspec.Files);
    builder.Files.Add(new PhysicalPackageFile()
    {
        SourcePath = value.Target,
        TargetPath = @"lib\" 
    });
}

using (FileStream stream = File.Open("bin\\Debug", FileMode.OpenOrCreate))
{
    builder.Save(stream);
}

I have hardcoded all the source paths, destination path, package info and metadata. But for some reason the package is not being created. Code runs without any errors.

1
  • Is is problem solved ? Commented Dec 31, 2015 at 9:00

1 Answer 1

1

I would guess it is probably being saved, but the file's name is Debug rather than x.nupkg.

using (FileStream stream = File.Open("bin\\Debug", FileMode.OpenOrCreate))
{                                    ^^^^^^^^^^^^
    builder.Save(stream);
}
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, sorry but that's not the problem. I tried both debug and dubug/a.nupkg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.