4

I successfully created and deployed a .NET Core App in Visual Studio 2015. It appears though that tooling and support for .NET Core in VS2015 is going away so I've decided to start fresh with VS2017. However the problem I'm running into is versioning. My hosting provider is running Plesk ~v12 and only supports a few of the run times, and definitely not the latest and greatest.

In VS2015 with the project.json I could target a specific run time version by modifying all the dependencies, however I can't see how to do this within Visual Studio 2017. My host has replied that they support "1.0.3" (Current version is 1.04 in the latest SDK) for .NET Core 1.0 apps, and "1.1.0 and 1.1.1" for .NET Core 1.1 apps. (Current version is 1.1.2 in the latest SDK)

When I deploy an application to my host, I receive the following error:

HTTP Error 502.5 - Process Failure

I believe this is caused because it is looking for runtime 1.0.4.

So, in a nutshell, how do I target the runtime version 1.0.3?

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
Adam Vincent
  • 3,281
  • 14
  • 38

2 Answers2

6

To set a specific version of the .Net Core runtime, you can add the <RuntimeFrameworkVersion> element to your csproj. For example, to use .Net Core 1.0.3, use:

<TargetFramework>netcoreapp1.0</TargetFramework>
<RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
svick
  • 236,525
  • 50
  • 385
  • 514
3

You can specify which SDK to use (even an older one) by adding a global.json file at the root of your solution.

{
    "sdk": { "version" : "1.0.3" }
}

In addition, it is possible to remotely install an SDK using this Powershell script, so if the SDK is not on the server you can install it. We are using this approach on our continuous integration server because the SDK we need is not installed on it.

NightOwl888
  • 55,572
  • 24
  • 139
  • 212
  • While this may still work with Visual Studio 2017, I don't think it will last very long since support for project.json has already been depricated. – Adam Vincent Jun 16 '17 at 03:58
  • 2
    Visual Studio 2017 still supports the `sdk` parameter in `project.json`, and it is not going away, although it doesn't support any other of the old `project.json` settings. See https://csharp.christiannagel.com/2017/01/10/dotnetcoreversionissues/. – NightOwl888 Jun 16 '17 at 04:03
  • Thanks for that link. Good info in there. – Adam Vincent Jun 16 '17 at 04:10
  • @NightOwl888, where do you read/see that `project.json` is not going away? Creating a new ASP.Net project in VS2017 gives you no `project.json` file at all. – Frank Fajardo Jun 16 '17 at 04:21
  • Essentially, no `project.json` file means that it will *always* use the latest version installed on the machine. You only need it if you wish to force it to use a prior version. That said, in your case it would probably be best to use it to ensure that your local copy is compiling on the `1.0.3` version of the SDK. – NightOwl888 Jun 16 '17 at 04:38
  • But I should point out that the SDK version you compile with has absolutely nothing to do with the *runtime* that your project is run on (as was in the original question). It only tells it which SDK to use when building the project. – NightOwl888 Jun 16 '17 at 04:39
  • I wasn't the one who asked the question but I was just curious about what you said on `project.json`. – Frank Fajardo Jun 16 '17 at 04:40
  • @NightOwl888 VS2017 supports the `sdk` parameter in *`global.json`*, not `project.json` (which I think never had an `sdk` parameter). – svick Jun 16 '17 at 14:29
  • Thanks. Error in my comment, unfortunately there is no way to edit comments after they have been up for 5 minutes. But my answer is correct. – NightOwl888 Jun 16 '17 at 15:38
  • While this answer may work, I believe it to be not as correct as the accepted answer. The SDK version is not the runtime version, and as far as I know, you can't specify a runtime version in the `global.json` If I specify the 1.0.3 SDK, that means I must have the 1.0.3 SDK downloaded and installed. With the `.csproj` file I can use the latest SDK (1.0.4 at the time of posting) and still target 1.0.3 runtime. Still your answer is informative, thank you NightOwl. – Adam Vincent Jun 17 '17 at 19:14