I deployed a .NET core RC2 app to a Windows / IIS machine running on EC2 today. Ran into a few issues and decided to write about it. This article got me most of the way there, and I encourage you to start there, but I ran into a few more issues.

First, configure IIS:

  1. Add a new website in IIS. Set its Physical Path to an empty folder of your choosing.
    • The article above encourages you to create a logs directory inside this path. Good a place as any for them.
    • Note that your wwwroot (or whatever folder you've configured in lieu of it) will get published inside of your IIS site's Physical Path. IIS will not use your wwwroot for its physical path - it merely hands off requests to Kestrel, which will serve static files from that physical path. If you've ever configured IIS to front for Tomcat, Jetty, stuff like that, this is exactly the same.
  2. Configure your new website to allow web deploy publishing.
  3. Copy the USERNAME_SITENAME.PublishSettings file created in the previous step to your local machine.
  4. Install .NET Core Windows Server Hosting on your server.
  5. Open a cmd prompt and run iisreset - note, this will restart all of your IIS sites, but it's needed to get IIS to recognize dotnet being added to the windows Path.
  6. After these steps, I was getting 502 gateway errors. Running via command line yielded this error (Did not find a suitable dotnet SDK at...). After trying a few other things, I ended up just installing the .NET Core SDK for Windows on the server, then everything worked.

Next, configure your VS project

  1. Open your project in Visual Studio, right click the project name, and click Publish.
    1. Click Import and choose the .PublishSettings file generated by your server.
    2. Double check the value in the server field is actually externally accessible - IIS might've generated https://machinename:8172/ or something - I just use "www.tim12.com" for example.
    3. Validate Connection - if it doesn't go through, you likely messed up configuring Web Deploy in step 2, or you're hitting either Windows or network firewalls - make sure TCP port 8172 inbound is open on your server. If you're using EC2 like me, go to your Security Groups and add an Inbound rule for TCP port 8172 - I lock it down to only allow access from my IP, but if your IP changes often and you deploy often, that can get annoying.
  2. Once your VS Publish Settings can Validate Connection successfully, move on to previewing the publish. You should see a list of all the files that need to go up to your server. Hit Publish once you've reviewed them.
    • For me, this failed with server SSL certificate problems. You can either make your machine trust your server's certificates, or just edit your project's Properties > PublishProfiles > YOURPUBLISHPROFILE.pubxml and add... <AllowUntrustedCertificate>True</AllowUntrustedCertificate> inside the <PropertyGroup> tag.
  3. Once publish completes, victory should be yours. Try hitting your site.

If you still have problems, this GitHub issue has a lot of potential issues / explanations / solutions