使用NuGet.Packaging打包nupkg文件
1、引用NuGet.Packaging包,其中NuGet.Core已被弃用。
2、采用以下代码
ManifestMetadata metadata = new ManifestMetadata() { Authors = new[] { "Marc" }, Version = new NuGet.Versioning.NuGetVersion("1.0.0.0"), Id = "myPackageIdentifier", Description = "A description", }; PackageBuilder builder = new PackageBuilder(); builder.PopulateFiles(folderPath, new[] {new ManifestFile() {Source = "**", Target = @"lib/net452"}}); builder.Populate(metadata); using(FileStream stream = File.Open(packagePath, FileMode.OpenOrCreate)) { builder.Save(stream); }