本文整理匯總了C#中NuGet.OptimizedZipPackage.GetDeployScript方法的典型用法代碼示例。如果您正苦於以下問題:C# OptimizedZipPackage.GetDeployScript方法的具體用法?C# OptimizedZipPackage.GetDeployScript怎麽用?C# OptimizedZipPackage.GetDeployScript使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NuGet.OptimizedZipPackage
的用法示例。
在下文中一共展示了OptimizedZipPackage.GetDeployScript方法的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);
}