当前位置: 首页>>代码示例>>C#>>正文


C# OptimizedZipPackage.GetDeployScript方法代码示例

本文整理汇总了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);
        }
开发者ID:kaanjin,项目名称:Monopus,代码行数:93,代码来源:DeployController.cs


注:本文中的NuGet.OptimizedZipPackage.GetDeployScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。