Skip to content

Instantly share code, notes, and snippets.

@jackawatts
Last active January 22, 2018 23:56
Show Gist options
  • Select an option

  • Save jackawatts/d379060906f96aa508ae89bd94900388 to your computer and use it in GitHub Desktop.

Select an option

Save jackawatts/d379060906f96aa508ae89bd94900388 to your computer and use it in GitHub Desktop.
VSTS with ASP.NET Core Build & Release (now with support for multiple agents on the same server!)

Configuring VSTS

Build

https://docs.microsoft.com/en-us/vsts/build-release/apps/aspnet/build-aspnet-core?tabs=vsts

Deployment

What follows can essentially be sourced from the link below: https://docs.microsoft.com/en-us/vsts/build-release/apps/cd/deploy-webdeploy-iis-deploygroups

1. Configure the Environment

.NET Core 2.0 https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x 2008R2

  1. Ensure .NET45 is installed: https://www.microsoft.com/en-au/download/details.aspx?id=42642
  2. Ensure PowerShell 3.0 or later is installed: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell?view=powershell-5.1
  3. Server Manager => Add Roles => Web Server
  4. Tick ASP.NET => Install
# Install the .NET Core SDK
Invoke-WebRequest https://go.microsoft.com/fwlink/?linkid=848827 -outfile $env:temp\dotnet-dev-win-x64.1.0.4.exe
Start-Process $env:temp\dotnet-dev-win-x64.1.0.4.exe -ArgumentList '/quiet' -Wait

# Install the .NET Core Windows Server Hosting bundle
Invoke-WebRequest https://aka.ms/dotnetcore-2-windowshosting -outfile $env:temp\DotNetCore.WindowsHosting.exe
Start-Process $env:temp\DotNetCore.WindowsHosting.exe -ArgumentList '/quiet' -Wait

# Restart the web server so that system PATH updates take effect
net stop was /y
net start w3svc

2012+

# Install IIS
Install-WindowsFeature Web-Server,Web-Asp-Net45,NET-Framework-Features

# Install the .NET Core SDK
Invoke-WebRequest https://go.microsoft.com/fwlink/?linkid=848827 -outfile $env:temp\dotnet-dev-win-x64.1.0.4.exe
Start-Process $env:temp\dotnet-dev-win-x64.1.0.4.exe -ArgumentList '/quiet' -Wait

# Install the .NET Core Windows Server Hosting bundle
Invoke-WebRequest https://aka.ms/dotnetcore-2-windowshosting -outfile $env:temp\DotNetCore.WindowsHosting.exe
Start-Process $env:temp\DotNetCore.WindowsHosting.exe -ArgumentList '/quiet' -Wait

# Restart the web server so that system PATH updates take effect
net stop was /y
net start w3svc

2. Create the Deployment Group/s

There should be 1 Deployment group created per Environment

  1. VSTS => 'Build & Release' => 'Deployment Groups'
  2. Add/New name
  3. Configure:
  • Name: Dev => Create
  1. Register Machines:
  • Type of Machine: Windows
  • Use a personal access token in the script for authentication => Copy script to clipboard
  1. Note the environment requires PowerShell 3.0 or higher: https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell?view=powershell-5.1
  2. Did you want multiple agents for the same project installed on the same server? => Edit the script copied from the clipboard and ensure the following 6.1 Ensure the default path is changed from $env:SystemDrive'vstsagent' to something else eg. $env:SystemDrive'vstsagent-dev' (this will appear multiple times) 6.2 Ensure the agent name is different. ie --agent "$env:COMPUTERNAME" to --agent "$env:COMPUTERNAME-DEV"
  3. Target Environment => In an Administrator PowerShell session: Execute the script
  4. Enter deployment group tags for agent? => Enter
  5. Enter User account to use for the service? => Enter
  6. Validate: VSTS => 'Build & Release' => 'Deployment Groups' => 'Targets'

3. Configure the Release Process

Information relating to configuring the app pool can be found here: https://docs.microsoft.com/en-us/aspnet/core/publishing/iis?tabs=aspnetcore2x

After a successful build

  1. VSTS => 'Build & Release' => 'Build Definitions' => Select the definition
  2. Summary => 'Recently Completed' => click on the version #
  3. Wait... => 'Release'
  4. Templates => 'IIS Website Deployment'
  5. Configure:
  • IIS Deployment => Deployment Group: Dev
  • IIS Web App Manage => Configure as per link above
  1. Pipeline => rename the environment to match the Deployment Group
  2. Add other environments, rinse repeat

Troubleshooting

netsh http url show uracl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment