正确的Azure Git支持的连续部署的部署脚本 [英] Correct deployment script for Azure Git backed continuous Deployment

查看:42
本文介绍了正确的Azure Git支持的连续部署的部署脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Angular 1.5的ASP.Net 4.5 MVC应用程序.JS代码是Typescript,构建后的操作将构建js代码并将其部署到我的应用程序引用的文件夹中.

I have a ASP.Net 4.5 MVC application which uses Angular 1.5. The JS code is Typescript and a post build action builds the js code and deploys it to the folder where my application refers to.

我的azure Web应用程序上有一个插槽,该插槽支持gitlab存储库.提交回购协议会触发部署,但是,当Bower/npm或类型库更新时(通过通过kudu控制台手动清除文件夹来解决),部署后的构建似乎经常会出现问题.是否有人有一个deploy.cmd脚本的示例,它相当于

I have a Slot on my azure web app which is backed my gitlab repo. Committing to the repo, triggers the deployment, however the post deployment build frequently seems to have issues when a bower/npm or typings library is updated (which is resolved by manually clearing the folder via the kudu console). Does someone have an example of a deploy.cmd script which does the equivalent of

  • npm安装
  • 类型安装

在管道中的正确位置,以便正确部署文件.我想从一个新的插槽开始,并且要使现有的插槽在过去工作,我不得不手动安装类型,例如"npm install typesing --global" 以获得版本可以正常工作而不会出现输入错误.

at the correct point in the pipeline so that the files get deployed correctly. I want to start scratch with a new slot, and to get the existing slot to work in the past i had to manually install typings for example "npm install typings --global" in order to get the build to work without a typings error.

更新下面的输出我猜下面的错误是由于在需要打字稿> 1.6的参考文件上运行天蓝色的打字稿1.6编译器而引起的.我的csproj具有< TypeScriptToolsVersion> 2.0</TypeScriptToolsVersion> (我从编译输出中删除了我的文件,但是_all.d.ts文件确实引用了下面的错误文件

Update Output Below I'm guessing that the errors below are due to azure running typescript 1.6 compiler over reference files which need typescript > 1.6. My csproj has <TypeScriptToolsVersion>2.0</TypeScriptToolsVersion> (ive removed my files from the compile output, but the _all.d.ts file does reference the errored files below

  CompileTypeScript:
  D:\Program Files (x86)\Microsoft SDKs\TypeScript\1.6\tsc.exe  --sourcemap --target ES5 --noEmitOnError "REMOVED MY TYPESCRIPTFILES" "D:\home\site\repository\mymvcproject\app\src\_all.d.ts"
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,32): error TS1110: Build: Type expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,50): error TS1005: Build: ']' expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,58): error TS1005: Build: ',' expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1824,59): error TS1136: Build: Property assignment expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
D:\home\site\repository\mymvcproject\typings\globals\angular\index.d.ts(1941,1): error TS1128: Build: Declaration or statement expected. [D:\home\site\repository\mymvcproject\mymvcproject.csproj]
Done Building Project "D:\home\site\repository\mymvcproject\mymvcproject.csproj" (Build;pipelinePreDeployCopyAllFilesToOneFolder target(s)) -- FAILED.

最终更新在打字稿团队最终生成了可以在Azure上安装的打字稿2. *版本之后,Kudu团队对其进行了部署.现在,整个过程都可以运行!下面有关使用

FINAL UPDATE After the typescript team finally generated a version of typescript 2.* which could be installed on Azure, and then the Kudu team deployed it. Now the whole process works! the note from below about using

"preinstall": "npm install typescript -g && npm install typings -g"

是解决方案的另一部分!

Was the other part of the solution!

推荐答案

根据您的要求,您可以按照以下步骤实现您的目的.

According to your requirement, you could follow the steps below to achieve your purpose.

创建部署脚本

您可以登录KUDU工具(https://.scm.azurewebsites.net/),单击工具">下载部署脚本".另外,您可以利用azure-cli生成脚本.有关如何通过azure-cli生成部署脚本的更多详细信息,可以参考此教程.

You could log in to KUDU tool (https://.scm.azurewebsites.net/), click "Tool" > "Download deployment script". Also, you could leverage azure-cli to generate the script. For more details about how to generate deployment script via azure-cli, you could refer to this tutorial.

自定义部署脚本

要使用NPM管理软件包,可以在package.json文件中添加以下脚本.

For using NPM to manage your packages, you could add the following scripts in your package.json file.

"scripts":{
    "preinstall": "npm install typescript -g && npm install typings -g"
 }

然后,您需要将以下脚本添加到deploy.cmd文件中.

Then, you need to add the following scripts to the deploy.cmd file.

IF EXIST "%DEPLOYMENT_SOURCE%\package.json" (
  pushd "%DEPLOYMENT_SOURCE%"
  echo installing npm package
  call :ExecuteCmd npm install --production
  IF !ERRORLEVEL! NEQ 0 goto error
  popd
)

或者您可以添加以下脚本来直接通过命令行安装打字稿和键入内容.

Or you could add the following scripts to install typescript and typings directly via command line.

echo Installing typescript and typings
call npm install typescript -g && npm install typings -g
IF !ERRORLEVEL! NEQ 0 goto error

注意:.deployment,deploy.cmd文件需要放置在解决方案的根目录中.有关详细信息,您可以参考此示例项目.

Note: The .deployment, deploy.cmd files need to be placed in the root directory of your solution. You could refer to this sample project for details.

这篇关于正确的Azure Git支持的连续部署的部署脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆