我想创建一个应用程序,使用NuGet包NuGet.Core。 它有一个称为PackageBuilder的类,可以实现这一点。 是否有任何可用的示例/教程/文档?
我想创建一个应用程序,使用NuGet包NuGet.Core。 它有一个称为PackageBuilder的类,可以实现这一点。 是否有任何可用的示例/教程/文档?
一个非常简单的例子:
编写如下代码:
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);
}
A row defining package file name.
ManifestMetadata metadata = new ManifestMetadata()
{
Authors = "mauvo",
Version = "1.0.0.0",
Id = "myPackageIdentifier",
Description = "A description",
};
PackageBuilder builder = new PackageBuilder();
var files = Directory.GetFiles(packagePath, "*", SearchOption.AllDirectories)
.Where(f => !f.EndsWith(".nuspec"))
.Select(f => new ManifestFile { Source = f, Target = f.Replace(path, "") })
.ToList();
builder.PopulateFiles("", files);
builder.Populate(metadata);
string packageFile = Path.Combine(packagePath, builder.GetFullName()) + ".nupkg";
using(FileStream stream = File.Open(packageFile, FileMode.OpenOrCreate))
{
builder.Save(stream);
}