Upgrading RC1 to DotNet Core RC2

Yeah, I know there are already a couple of definitive guides to this already on the net, but here's the checklist I compiled for myself when I had to upgrade several RC1 projects. I'll just leave this here in case someone else can make use of it or in case I need to re-reference it some time in the future.

If you are upgrading a project to RC2, all RC1 dependencies should be upgraded to RC2 to avoid conflicts - that means if you wrote a NuGet package that uses RC1 libraries, your API service consumes this NuGet package and you are upgrading the service to RC2, then you should upgrade the RC1 based NuGet package to RC2 in addition to upgrade the API service. You should of course have upgraded to Visual Studio 2015 Update 2 at least before continuing.

1) Upgrade xproj files (best to do this with something like notepad)
1.1) Replace
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
with
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
1.2.) If Web/ project, replace
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
with
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
1.3) If class library, replace
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
with
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
1.4) Replace
..\..\artifacts\obj\$(MSBuildProjectName)
with
.\obj
1.5) Replace
..\..\artifacts\bin\$(MSBuildProjectName)\
with
.\bin\
1.6) Add new line after </OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

The next steps can be easily accomplished from inside of Visual Studio

2) Edit global.json
2.1) Remove the sdk section
3) Move the web.config
3.1) If the project has a web.config, move it out of the wwwroot folder to the root folder of the project
4) Edit project.json files
4.1) Replace

       "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
       "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
       "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
       "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
       "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
       "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
       "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
       "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
       "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",

with

       "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
       "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
       "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
       "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
       "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
       "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
       "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
       "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
       "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",

4.2) Replace
"AspNet.Mvc.TypedRouting": "1.0.2-rc1-final",
with
"AspNet.Mvc.TypedRouting": "1.1.0-rc2-final"
4.3) Replace
"Microsoft.AspNetCore.Tooling.Razor": "1.0.0-rc1-final"
with

"Microsoft.AspNetCore.Razor.Tools": {
     "version": "1.0.0-preview1-final",
     "type": "build"
   }

4.4) Replace frameworks (my projects only ever used one framework)
"net451" or "dnx451"
with
"net461"
4.5) If you had a reference to:

        "frameworkAssemblies": {
          "System.Runtime.Serialization": "4.0.0.0"
        }

remove it, and add to the dependencies section
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-24027"
4.6) If you had a reference to:

        "frameworkAssemblies": {
          "System.ComponentModel.DataAnnotations": "4.0.0.0"
        }

remove it, and add to the dependencies section
"System.ComponentModel.Annotations": "4.1.0-rc2-24027"
4.7) Remove sections licenseUrl, projectUrl, tags, commands, exclude, and publishExclude
4.8) Update minor version number if not major version number
4.9) Replace

     "compilationOptions": {
       "emitEntryPoint": true
     },

with

     "buildOptions": {
       "emitEntryPoint": true,
       "preserveCompilationContext": true
     },

4.10) Remove commands section
4.11) If web/api project, add

     "tools": {
       "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
         "version": "1.0.0-preview1-final",
         "imports": "portable-net45+win8+dnxcore50"
       }
     },
     "publishOptions": {
       "include": [
         "wwwroot",
         "Views",
         "appsettings.json",
         "web.config"
       ]
     },
     "runtimeOptions": {
       "configProperties": {
         "System.GC.Server": true
       }
     },
     "scripts": {
       "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
     },

4.12) Replace any project reference versions in dependencies with
{ "target": "project" }
4.13) If it is a test project
4.13.1) Replace
"xunit.runner.dnx": "2.1.0-rc1-build204"
with
"dotnet-test-xunit": "1.0.0-rc2-build10025"
4.13.2) Replace
"Microsoft.AspNet.TestHost": "1.0.0-rc1-final",
with
"Microsoft.AspNetCore.TestHost": "1.0.0-rc2-final",
4.13.3) Add
"testRunner": "xunit", 4.13.5) Remove sections tooling, description, authors
4.14) If web or test project, add

     "tools": {
       "Microsoft.DotNet.Watcher.Tools": {
         "version": "1.0.0-preview1-final",
         "imports": "portable-net451+win8"
       }}

5) Edit launchSettings.json
5.1) Replace
"Hosting:Environment" with
"ASPNETCORE_ENVIRONMENT" 6) Edit web.config
6.1) Replace

     <system.webServer>
       <handlers>
         <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
       </handlers>
       <httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
     </system.webServer>

with

   <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
      </handlers>
      <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
    </system.webServer>

7) Edit appsettings.json
7.1 ) Replace
"Default": "Verbose",
with
"Default": "Debug",
8) If your project used Entity Framework 7, you will need to downgrade to Entity Framework 6. EF7 rc2 is not ready for prime time. For example, it has problems with GUID foreign keys. I might write in detail the steps necessary to do this.
8) Edit .Net code
8.1) Change any IServiceCollection.AddInstance method calls to IServiceCollection.AddSingleton
8.2) Change Microsoft.Extensions.Logging.LogLevel.Verbose to Microsoft.Extensions.Logging.LogLevel.Trace
8.3) Replace Microsoft.AspNet namespace references with Microsoft.AspNetCore
8.4) Replace HttpNotFound with NotFound
8.5) Replace HttpBadRequest with BadRequest
8.6) Replace HttpStatusCodeResult with StatusCodeResult
8.7) Replace HttpOkObjectResult with OkObjectResult
8.8) Replace ContentResult.ContentType.MediaType with ContentResult.ContentType
8.9) Replace GetType().Assembly with GetType().GetTypeInfo().Assembly
8.10) Add using System.Reflection; if necessary
8.11) Add ".SetBasePath(env.ContentRootPath)" after "new ConfigurationBuilder()"
8.12) Remove calls to UseIISPlatformHandler
8.13) Remove calls to UseStaticFiles
8.14) Replace

      public static void Main(string[] args) => WebApplication.Run<Startup>(args);

with

      public static void Main(string[] args) =>
               new WebHostBuilder()
                   .UseKestrel()
                   .UseContentRoot(Directory.GetCurrentDirectory())
                   .UseIISIntegration()
                   .UseStartup<Startup>()
                   .Build().Run();

9) Routes in web apps need to not include IIS application paths anymore. Back in RC1 the routes had to include every part of the URL following the domain name. In RC2, you only need to include the part of the URL that follows the URL to the web application in IIS.
10) Edit build scripts
10.1) Replace

#include the path to NodeJS, necessary for npm, boiwer, gulp, etc to run
        $Env:Path += ";.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External\git;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\External"

with

#include the path to NodeJS, necessary for npm, bower, gulp, etc to run
        $Env:Path += ";.\node_modules\.bin;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git"