0

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:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:"C:\CIDeploy\webapp.SetParameters.xml"

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

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

Thanks in advance.

Giulio Vian
  • 8,248
  • 2
  • 33
  • 41
Krishna joshi
  • 293
  • 1
  • 2
  • 9
  • are you running as administrator? – ste-fu Dec 02 '16 at 11:12
  • yes,I have logged in as administrator user account into my computer. – Krishna joshi Dec 02 '16 at 11:14
  • @Krishnajoshi What's the result if you are using WinRM-IIS Web App Deployment task/step to deploy your project? – starian chen-MSFT Dec 08 '16 at 02:15
  • @starain-MSFT I am also new to this but according to documentation this step will create a website into IIS server running on target server by connecting through WinRm service. I am facing the following issue *when using HTTPS Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. When using HTTP Access is denied. – Krishna joshi Dec 08 '16 at 05:57
  • @Krishnajoshi Do you mean you want to deploy app by using HTTP protocol? – starian chen-MSFT Dec 08 '16 at 06:23
  • @starain-MSFT I am going through the doc as link below https://www.visualstudio.com/en-us/docs/release/examples/other-servers/net-to-vm.This is the process what i want to do.Please help me – Krishna joshi Dec 08 '16 at 06:47
  • @Krishnajoshi What's the problems now? For ConfigureWinRM.ps file, you can refer to it here (https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/PowerShellOnTargetMachines/ConfigureWinRM.ps1) – starian chen-MSFT Dec 08 '16 at 08:53
  • Sorry above link was incorrect.the correct link is https://www.visualstudio.com/en-us/docs/release/examples/other-servers/net-to-vm – Krishna joshi Dec 08 '16 at 08:53
  • @Krishnajoshi I added detail steps in my answer, you can check it. – starian chen-MSFT Dec 08 '16 at 10:43

2 Answers2

2

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

  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)

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

Update:

Detail steps:

  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") enter image description here
  14. Add Windows Machine File Copy step/task enter image description here
  15. Add WinRM- IIS Web App Management step/task enter image description here
  16. Add WinRM-IIS Web App Deployment step/task enter image description here

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

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
0

You cannot deploy locally on a Hosted Agent: you must deploy to another machine. The easiest way is to use VSTS Resource Management and and Agent running on the target machine with administrative privileges (I would suggest to run it non-admin and grant in IIS permission to the user to deploy).

Giulio Vian
  • 8,248
  • 2
  • 33
  • 41