本文整理汇总了C#中NuGet.ZipPackage.GetContentFiles方法的典型用法代码示例。如果您正苦于以下问题:C# ZipPackage.GetContentFiles方法的具体用法?C# ZipPackage.GetContentFiles怎么用?C# ZipPackage.GetContentFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NuGet.ZipPackage
的用法示例。
在下文中一共展示了ZipPackage.GetContentFiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine("Create NuGet Package via Code");
ManifestMetadata metadata = new ManifestMetadata()
{
Authors = "Authors Name",
Version = "1.0.0.0",
Id = "NuGetId",
Description = "NuGet Package Description goes here!",
};
PackageBuilder builder = new PackageBuilder();
var path = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\DemoContent\\";
builder.PopulateFiles(path, new[] { new ManifestFile { Source = "**", Target = "content" } });
builder.Populate(metadata);
using (FileStream stream = File.Open("test.nupkg", FileMode.OpenOrCreate))
{
builder.Save(stream);
}
Console.WriteLine("... and extract NuGet Package via Code");
NuGet.ZipPackage package = new ZipPackage("test.nupkg");
var content = package.GetContentFiles();
Console.WriteLine("Package Id: " + package.Id);
Console.WriteLine("Content-Files-Count: " + content.Count());
Console.ReadLine();
}
示例2: installPackageToAppDir
//
// ApplyReleases methods
//
List<string> installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release)
{
var pkg = new ZipPackage(Path.Combine(rootAppDirectory, "packages", release.Filename));
var target = getDirectoryForRelease(release.Version);
// NB: This might happen if we got killed partially through applying the release
if (target.Exists) {
Utility.DeleteDirectory(target.FullName).Wait();
}
target.Create();
// Copy all of the files out of the lib/ dirs in the NuGet package
// into our target App directory.
//
// NB: We sort this list in order to guarantee that if a Net20
// and a Net40 version of a DLL get shipped, we always end up
// with the 4.0 version.
pkg.GetLibFiles().Where(x => pathIsInFrameworkProfile(x, appFrameworkVersion))
.OrderBy(x => x.Path)
.ForEach(x => CopyFileToLocation(target, x));
pkg.GetContentFiles().ForEach(x => CopyFileToLocation(target, x));
var newCurrentVersion = updateInfo.FutureReleaseEntry.Version;
// Perform post-install; clean up the previous version by asking it
// which shortcuts to install, and nuking them. Then, run the app's
// post install and set up shortcuts.
return runPostInstallAndCleanup(newCurrentVersion, updateInfo.IsBootstrapping);
}
示例3: ContentFilesAreIncludedInCreatedPackage
public void ContentFilesAreIncludedInCreatedPackage()
{
var inputPackage = IntegrationTestHelper.GetPath("fixtures", "ProjectWithContent.1.0.0.0-beta.nupkg");
var outputPackage = Path.GetTempFileName() + ".nupkg";
var sourceDir = IntegrationTestHelper.GetPath("fixtures", "packages");
var fixture = new ReleasePackage(inputPackage);
(new DirectoryInfo(sourceDir)).Exists.ShouldBeTrue();
try {
fixture.CreateReleasePackage(outputPackage, sourceDir);
this.Log().Info("Resulting package is at {0}", outputPackage);
var pkg = new ZipPackage(outputPackage);
int refs = pkg.FrameworkAssemblies.Count();
this.Log().Info("Found {0} refs", refs);
refs.ShouldEqual(0);
this.Log().Info("Files in release package:");
var contentFiles = pkg.GetContentFiles();
Assert.Equal(2, contentFiles.Count());
var contentFilePaths = contentFiles.Select(f => f.EffectivePath);
Assert.Contains("some-words.txt", contentFilePaths);
Assert.Contains("dir\\item-in-subdirectory.txt", contentFilePaths);
Assert.Equal(1, pkg.GetLibFiles().Count());
} finally {
File.Delete(outputPackage);
}
}
示例4: installPackageToAppDir
async Task<string> installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release)
{
var pkg = new ZipPackage(Path.Combine(updateInfo.PackageDirectory, release.Filename));
var target = getDirectoryForRelease(release.Version);
// NB: This might happen if we got killed partially through applying the release
if (target.Exists) {
this.Log().Warn("Found partially applied release folder, killing it: " + target.FullName);
await Utility.DeleteDirectory(target.FullName);
}
target.Create();
// Copy all of the files out of the lib/ dirs in the NuGet package
// into our target App directory.
//
// NB: We sort this list in order to guarantee that if a Net20
// and a Net40 version of a DLL get shipped, we always end up
// with the 4.0 version.
this.Log().Info("Writing files to app directory: {0}", target.FullName);
var toWrite = pkg.GetLibFiles().Where(x => pathIsInFrameworkProfile(x))
.OrderBy(x => x.Path)
.ToList();
// NB: Because of the above NB, we cannot use ForEachAsync here, we
// have to copy these files in-order. Once we fix assembly resolution,
// we can kill both of these NBs.
await Task.Run(() => toWrite.ForEach(x => copyFileToLocation(target, x)));
await pkg.GetContentFiles().ForEachAsync(x => copyFileToLocation(target, x));
return target.FullName;
}