Deploying via Octopus Deploy on ASP.NET Core RC1

Written by William Roush on March 18, 2016 at 5:34 pm

This guide shows you how I got ASP.NET Core RC1 deploying via Octopus, this may change in the future as ASP.NET Core continues to mature.

First, if you write and deploy .NET applications, get your hands on Octopus Deploy, seriously it’s worth every penny. They have a free edition for smaller deployments, I use it for my clients and at work and it’s a huge time saver and helps improve reliability of deploys greatly.

Preparing Your Project

Because Octopus Deploy doesn’t support .NET Core yet, we’re going to build our own package using a nuspec file, so you need to create one like this:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
 <metadata>
 <id>RoushTech.Resume.Website</id>
 <version>1.0.0</version>
 <authors>William Roush</authors>
 <description>RoushTech.Resume.Website</description>
 </metadata>
 <files>
 <file src="..\..\published-webapp\**\*.*"/>
 </files>
</package>

This will allow us to package our application after we publish it into our published-webapp directory later.

Preparing Your Build Server

I use TeamCity to build my projects, I’m going to add a step for packaging our deployment, which is a simple command I’ll run on the command line thanks to .NET Core’s ease of use on the command line.

dnu publish --runtime active --no-source -o ..\..\published-webapp

This will cause our application to get published right where our nuspec file expects it. We’ll run nuget.exe pack against our nuspec file located at src/RoushTech.AspNetCoreProject/RoushTech.AspNetCoreProject.nuspec.

Preparing Your Web Server

You’ll need to install the HTTP Platform Handler detailed in the ASP.NET Core Documentation

Configuring Your Project

We’re going to configure a normal IIS project, the relative home directory is “wwwroot”, and we want a post-deployment script using the code below:

#Load Web Admin DLL
[System.Reflection.Assembly]::LoadFrom("C:\windows\system32\inetsrv\Microsoft.Web.Administration.dll")
Add-PSSnapin WebAdministration -ErrorAction SilentlyContinue
Import-Module WebAdministration -ErrorAction SilentlyContinue
$iis = (New-Object Microsoft.Web.Administration.ServerManager)
$pool = $iis.ApplicationPools | Where {$_.Name -eq $OctopusParameters['Octopus.Action[Deploy].IISWebSite.ApplicationPoolName']} | Select-Object -First 1
$pool.ManagedRuntimeVersion = ""

This will set the runtime version to “No Managed Code”, it’s kind of a hack until Octopus adds support.

Updated: Dalmiro pointed out in the comments that the issue can be voted for here, I’ve already put in my vote!

Deploy!

And there you have it, running Octopus Deploy should deploy your new ASP.NET Core RC1 Website out to production, we’ll update this as RC2/Gold comes out because they’ll be changing some commands on us.

Share on LinkedInShare on FacebookShare on TumblrTweet about this on TwitterShare on StumbleUponShare on RedditShare on Google+Email this to someone

2 thoughts on “Deploying via Octopus Deploy on ASP.NET Core RC1

    1. William Roush Post author

      Sweet! I had poked around the suggestions but apparently didn’t really put any effort into it. Voted!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.