本文整理汇总了C#中NuGet.ZipPackage.ExtractContents方法的典型用法代码示例。如果您正苦于以下问题:C# ZipPackage.ExtractContents方法的具体用法?C# ZipPackage.ExtractContents怎么用?C# ZipPackage.ExtractContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NuGet.ZipPackage
的用法示例。
在下文中一共展示了ZipPackage.ExtractContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
//download the specified version of the package and update project reference to it. The newly downloaded package
//will be located in /packages folder. The updated project reference can be checked in corresponding .csproj file.
public bool Execute(string packageid, string projectFile, SemanticVersion version, string packages)
{
try
{
System.Console.WriteLine("-------------------------------------");
System.Console.WriteLine("Project File " + projectFile);
System.Console.WriteLine("Package "+packageid);
System.Console.WriteLine("Version "+version);
IPackageRepository repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2");
var packagePathResolver = new DefaultPackagePathResolver(packages);
var packagesFolderFileSystem = new PhysicalFileSystem(packages);
var projectSystem = new MSBuildProjectSystem(projectFile);
var localRepository = new LocalPackageRepository(packagePathResolver, packagesFolderFileSystem);
var projectManager = new ProjectManager(repo, packagePathResolver, projectSystem, localRepository);
projectManager.RemovePackageReference(packageid,true,false);
projectManager.AddPackageReference(packageid, version, true, false);
projectSystem.Save();
string filename = packageid + "." + version;
string[] s = Directory.GetFiles(packages+ @"\"+filename);
if (s.IsEmpty()) { System.Console.WriteLine("empty"); }
else
{
var nupkgFile = new PhysicalFileSystem(s[0]);
ZipPackage z = new ZipPackage(s[0]);
z.ExtractContents(nupkgFile, packages + @"\" + filename);
}
System.Console.WriteLine("Successfully updated");
return true;
}
catch (Exception e)
{
System.Console.Write("failure");
System.Console.Write(e.StackTrace);
return false;
}
}