在具有连续部署的IIS服务器中自动部署ASP.Net MVC网站

问题描述:

我正在尝试从Visual Studio Team Services Build部署Web应用程序.我正在使用Visual Studio Build任务来构建项目.然后,使用命令行任务执行生成的release.deploy.cmd,以将其部署在IIS服务器中.在执行时,我面临以下问题:

I'm trying to deploy a web application from Visual Studio Team Services Build. I'm using Visual Studio Build task to build the project. Then, use command line task to execute generated release.deploy.cmd to deploy in IIS server. On executing, I faced the below issue:

E"C:\ Program Files \ IIS \ Microsoft Web Deploy V3 \ msdeploy.exe" -source:package ='C:\ CIDeploy \ webapp.zip'-dest:auto,includeAcls ="False" -verb:同步-disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"C:\ CIDeploy \ webapp.SetParameters.xml"

E"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:package='C:\CIDeploy\webapp.zip' -dest:auto,includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"C:\CIDeploy\webapp.SetParameters.xml"

2016-12-02T10:29:18.2576272Z警告:BACKUP_FAILED-跳过备份,因为由于未知原因备份失败.┬á有关更多信息,请与服务器管理员联系. 2016-12-02T10:29:18.2586324Z跳过备份,因为由于以下错误'System.UnauthorizedAccessException:文件名:redirection.config

2016-12-02T10:29:18.2576272Z Warning: BACKUP_FAILED - Skipping backup because it failed due to an unknown reason. For more information, contact your server administrator. 2016-12-02T10:29:18.2586324Z Skipping backup because it failed due to the following error 'System.UnauthorizedAccessException: Filename: redirection.config

错误:读取IIS配置文件"MACHINE/REDIRECTION"时发生错误.执行该操作的身份为"TASKAGENT5-0017 \ buildguest".

Error: An error occurred when reading the IIS Configuration File 'MACHINE/REDIRECTION'. The identity performing the operation was 'TASKAGENT5-0017\buildguest'.

2016-12-02T10:29:18.4396280Z错误:文件名:\?\ C:\ Windows \ system32 \ inetsrv \ config \ redirection.config 2016-12-02T10:29:18.4396280Z错误:由于权限不足而无法读取配置文件

2016-12-02T10:29:18.4396280Z Error: Filename: \?\C:\Windows\system32\inetsrv\config\redirection.config 2016-12-02T10:29:18.4396280Z Error: Cannot read configuration file due to insufficient permissions

谢谢.

使用WinRM-IIS Web App部署任务/步骤来部署Web项目.

Using WinRM-IIS Web App Deployment task/step to deploy your web project.

  1. 安装使用WinRM进行IIS Web应用程序部署扩展
  2. 将WinRM-IIS Web App管理步骤/任务添加到您的构建/发行版定义中
  3. 指定必要的参数(例如,管理员登录名,密码)
  1. Install IIS Web App Deployment Using WinRM extension
  2. Add WinRM-IIS Web App Management step/task to your build/release definition
  3. Specify necessary arguments (e.g. Admin Login, Password)

另一方面,还有其他扩展名在可以部署Web项目的市场中.

On the other hand, there are others extension in marketplace that can deploy web project.

更新:

详细步骤:

  1. 下载或创建ConfigureWinRM.ps1文件(源代码)
  2. 转到目标服务器(IIS)
  3. 以管理员身份启动Windows PowerShell
  4. 转到(CD命令)包含ConfigureWinRM.ps1文件的路径
  5. 运行.\ ConfigureWinRM.ps1 [带域的计算机名称] https
  6. 打开Microsoft管理控制台(MMC)(在运行"命令(win + R)中键入mmc)
  7. 文件=>添加/删除管理单元=>选择证书=>添加=>确定
  8. 扩展证书(本地计算机)=>个人=>证书
  9. 根据颁发给(第5步)选择证书文件
  10. 右键单击它=>所有任务=>导出以导出证书文件
  11. 将导出的文件复制到构建服务器
  12. 双击该文件=>安装证书=>本地计算机=>将所有证书放在以下存储中=>受信任的根证书颁发机构
  13. 添加Visual Studio Build步骤/任务(MSBuild参数:/p:SkipInvalidConfigurations = true/p:DeployOnBuild = true/p:WebPublishMethod = Package/p:PackageLocation="$(build.artifactstagingdirectory)\WebGeneralDemo.zip)
  14. 添加Windows Machine File Copy步骤/任务
  15. 添加WinRM- IIS Web App管理步骤/任务
  16. 添加WinRM-IIS Web App部署步骤/任务
  1. Download or create ConfigureWinRM.ps1 file (source code)
  2. Go to target server (IIS)
  3. Start Windows PowerShell as Administrator
  4. Go to (CD command) the path that contains ConfigureWinRM.ps1 file
  5. Run .\ConfigureWinRM.ps1 [machine name with domain] https
  6. Open Microsoft Management Console (MMC) (Type mmc in Run command (win+R))
  7. File=>Add/Remove Snap-in=>Select Certificates=>Add=>Ok
  8. Expand Certificate (Local Computer)=>Personal=>Certificates
  9. Select the certificate file according to the Issued to (step 5)
  10. Right click it=>All task=>Export to export certificate file
  11. Copy exported file to your build server
  12. Double click that file=>Install Certificate=>Local Machine=>Place all certificates in following store=>Trusted Root Certification Authorities
  13. Add Visual Studio Build step/task (MSBuild argument: /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageLocation="$(build.artifactstagingdirectory)\WebGeneralDemo.zip")
  14. Add Windows Machine File Copy step/task
  15. Add WinRM- IIS Web App Management step/task
  16. Add WinRM-IIS Web App Deployment step/task

顺便说一句:您可以将部署任务发布(请参阅该文章)

BTW: you can put deploy task in release (refer to that article)