How to create a NuGet Package using NuGet.Core?

后端 未结 2 1977
时光取名叫无心
时光取名叫无心 2021-02-04 02:48

I would like to create a application which makes use of the NuGet Package NuGet.Core. It has a class called PackageBuilder that makes it possible. Is there any sample / tutorial

2条回答
  •  时光说笑
    2021-02-04 03:32

    A really simple example:

    1. create a folder containing the files you want in your package.
    2. Write some code like this:

      
      ManifestMetadata metadata = new ManifestMetadata()
          {
              Authors = "mauvo",
              Version = "1.0.0.0",
              Id =  "myPackageIdentifier",
              Description = "A description",
          };
      
      PackageBuilder builder = new PackageBuilder();
      builder.PopulateFiles("folderPath/", new[] {new ManifestFile() {Source = "**"}});
      builder.Populate(metadata);
      using(FileStream stream = File.Open(packagePath, FileMode.OpenOrCreate))
      {
          builder.Save(stream);
      }
      

提交回复
热议问题