本文整理汇总了C#中NuGet.OptimizedZipPackage.Uninstall方法的典型用法代码示例。如果您正苦于以下问题:C# OptimizedZipPackage.Uninstall方法的具体用法?C# OptimizedZipPackage.Uninstall怎么用?C# OptimizedZipPackage.Uninstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NuGet.OptimizedZipPackage
的用法示例。
在下文中一共展示了OptimizedZipPackage.Uninstall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Upload
public async Task<IHttpActionResult> Upload()
{
if (!Request.Content.IsMimeMultipartContent())
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
var provider = new MultipartMemoryStreamProvider();
await Request.Content.ReadAsMultipartAsync(provider);
string output = null;
foreach (var file in provider.Contents)
{
var filename = file.Headers.ContentDisposition.FileName.Trim('\"');
if (!Directory.Exists(_sourcePath))
Directory.CreateDirectory(_sourcePath);
var path = Path.Combine(_sourcePath, filename);
using (var stream = File.Create(path))
{
var s = await file.ReadAsByteArrayAsync();
await stream.WriteAsync(s, 0, s.Length);
}
if (!PackageHelper.IsPackageFile(path))
{
var ex = new Exception("File is not a package!");
Log.Error(ex);
return InternalServerError(ex);
}
var pkg = new OptimizedZipPackage(path);
try
{
await pkg.Uninstall(_sourcePath, _deployOption.InstallPath);
}
catch (InvalidOperationException ex)
{
Log.Error(ex);
if (!ex.Message.StartsWith("Unable to find package"))
throw;
}
catch (TimeoutException ex)
{
Log.Error(ex);
}
catch (Exception ex)
{
Log.Error(ex);
return InternalServerError(ex);
}
string installPath;
try
{
installPath = await pkg.Install(_sourcePath, _deployOption.InstallPath);
}
catch (Exception ex)
{
Log.Error(ex);
return InternalServerError(ex);
}
string deployScript;
if ((deployScript = await pkg.GetDeployScript()) != null)
{
var args = new ListDictionary
{
{"installPath", installPath},
{"toolsPath", Path.Combine(installPath, "tools")},
{"package", pkg},
{"project", null}
};
if (!Script.Execute(deployScript, args, ref output))
{
var ex = new Exception(output);
Log.Error(ex);
return InternalServerError(ex);
}
}
}
Log.InfoFormat("Deploy success: {0}", output);
return Ok(output);
}