本文整理匯總了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;
}
}