Your ASP.NET Core 1.1 Not Working? Check Out This Solution! – Windows ASP.NET Core Hosting 2020 | Review and Comparison
 

Previously, I wrote about ASP.NET Core 1.1 new release. Then, I tested this new features and face issue when upgrading my ASP.NET Core project. Some of you maybe face the error when upgrading your ASP.NET version to ASP.NET Core 1.1. Stay tuned on this post and hope it will help you to resolve your problem!

  1. Let’s get started. For your information, I install .NET Core 1.1 on my Windows 10 here and I got 2 issues.

Install ASP.NET Core 1.1

I began to install ASP.NET Core on my Windows machine from Microsoft page. I followed all the instructions to install it. The installation is very quick and running smoothly.

Then, Create My First ASP.NET Core 1.1 Project

According to the blog post, once you’ve run the installer you should be able to start creating 1.1.0 applications. Running dotnet new with the .NET CLI should create a new 1.1.0 application, with a project.json that contains an updated Microsoft.NETCore.App dependency, looking something like:

"frameworks": {
  "netcoreapp1.0": {
    "dependencies": {
      "Microsoft.NETCore.App": {
        "type": "platform",
        "version": "1.1.0"
      }
    },
    "imports": "dnxcore50"
  }
}

So I created a sub folder for a test project, ran dotnet new and eagerly checked the project.json:

"frameworks": {
  "netcoreapp1.0": {
    "dependencies": {
      "Microsoft.NETCore.App": {
        "type": "platform",
        "version": "1.0.0"
      }
    },
    "imports": "dnxcore50"
  }
}

I found that the project still running on ASP.NET Core 1.0, not ASP.NET Core 1.1. This is the problem.

Check the global.json

If you face same issue like me, check your global.json file. When you created your first RC2 project, you might create folder testing dotnet new. Here is what I found:

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-preview2-003121"
  }
}

Nah!… Found the problem…. If an SDK version is specified in global.json then it will be used preferentially over the latest tooling. Updating the sdk section with the appropriate value, or removing the SDK section means the latest tooling should be used, which should let me create my 1.1.0 project.

Remove Section

After removing the sdk section of the global.json, I ran dotnet new again, and checked the project.json:

"frameworks": {
  "netcoreapp1.0": {
    "dependencies": {
      "Microsoft.NETCore.App": {
        "type": "platform",
        "version": "1.0.0"
      }
    },
    "imports": "dnxcore50"
  }
}

Make sure you check SDK installed on your local computer. I found this file system on:

/usr/local/share/dotnet/sdk/

There’s quite a few different versions of the SDK in there, including the 1.0.0 RTM version (1.0.0-preview2-003121) and also the 1.1.0 Preview 1 version (1.0.0-preview2.1-003155). However there’s also a slightly odd one that stands out – 1.0.0-preview3-003213. (Note, with the 1.1 RTM there is a whole new version, 1.0.0-preview2-1-003177)

Most people installing the .NET Core SDK will not run into this issue, as they likely won’t have this additional preview3 version. I only have it installed (I think) because I created a couple of pull requests to the ASP.NET Core repositories recently. The way versioning works in the ASP.NET Core repositories for development versions means that although there is a preview3 version of the tooling, it is actually older that the preview2.1 version of the tooling just released, and generates 1.0.0 projects.

When you run dotnet new, and in the absence of a global.json with an sdk section, the CLI will use the most recent version of the tooling as determined by SemVer. Consequently, it had been using the preview3 version and generating 1.0.0 projects!

The simple solution was to delete the 1.0.0-preview3-003213 folder, and re-run dotnet new:

"frameworks": {
  "netcoreapp1.0": {
    "dependencies": {
      "Microsoft.NETCore.App": {
        "type": "platform",
        "version": "1.1.0-preview1-001100-00"
      }
    },
    "imports": "dnxcore50"
  }
}

You are ready now for new ASP.NET 1.1 project!

Summary

You may face issue like me when upgrading to ASP.NET Core 1.1. If you have other experiences, please share your issue here. My problem above is because global.json and maybe some of you have same experience like me.