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.
Hi Will – Nice post! Just so you know, there’s a uservoice sugestion to add support to set app pools to “No Managed Code” https://octopusdeploy.uservoice.com/forums/170787-general/suggestions/12522726-ability-to-set-application-pool-clr-to-no-managed . Votes there are the best way to make it happen.
Cheers
Sweet! I had poked around the suggestions but apparently didn’t really put any effort into it. Voted!