12

I'm trying to run a .NET Core application on my Windows Server 2016 instance. It builds/runs fine on my Windows 10 machine.

First I'm doing dotnet publish and I copy the published site to the Windows Server instance. I followed this guide and installed both the hosting bundle as well as the latest SDK (2.1.3).

However when I try to dotnet myapp.dll i get the following error message:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.All', version '2.1.1' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]

I can see clearly that indeed Microsoft.AspNetCore.All only has a 2.1.0 version located in Program Files\dotnet\shared. How do I get the correct 2.1.1 version?

Any guidance is highly appreciated.

Ropstah
  • 17,538
  • 24
  • 120
  • 194
  • Have you tried publishing with `dotnet publish --self-contained`? – DavidG Jun 19 '18 at 00:58
  • I did not, this solves my problem without changing the source code and I'm deploying it manually anyway. Great! – Ropstah Jun 19 '18 at 09:41
  • Update: I ended up trying the other methods as well and ended up installing the latest package. Open source ftw – Ropstah Jun 19 '18 at 15:18
  • Considering the 2.1.1 SDK isn't released yet, have you actually installed the preview? – DavidG Jun 19 '18 at 15:22
  • @DavidG: Hmm I'm not sure actually, I thought it was the `2.1.300` version which _was_ released (https://www.microsoft.com/net/download/windows), however I did take a preview version of the thing again at `2.1.301` – Ropstah Jun 21 '18 at 10:09
  • Well the link provided in the accepted answer points to the preview version of the v2.1.1 of the SDK. The live version is still not yet released (it's stuck in the release process still). If you're using v2.1 though, you will be OK. – DavidG Jun 21 '18 at 10:17
  • The link shows .NET SDK on `refs/heads/release/2.1.3xx` from which i got the `301` version. The MSFT site shows .NET SDK for `2.1.300`... – Ropstah Jun 21 '18 at 22:13

3 Answers3

11

Use this link to install 2.1.1 core sdk version:

https://github.com/dotnet/versions/tree/7a833dddfddc27f2074b755b94234a25b9757637/build-info/dotnet/product/cli/release/2.1

Jourmand
  • 888
  • 10
  • 27
  • Great, I wasn't able to find this raw build! – Ropstah Jun 19 '18 at 09:43
  • @DavidG's method worked using a `--self-contained` build. However I installed the package in this answer and that has my preference as I don't have to change my development environment for it to work. I had to restart the server for the changes to take effect, simply restarting the IIS services didn't work. – Ropstah Jun 19 '18 at 11:33
  • 1
    [Being aware of the caveats is also important.](https://github.com/aspnet/Home/wiki/.NET-Core-2.1.1-Early-Access-Downloads) – Alternatex Jun 20 '18 at 19:57
4

Looks like there's been some issue with publishing the Microsoft.AspNetCore.All package, and it is not set to automatically install with VS update/Core SDK install. At least not for me. The nuget package was also added just 10 hours ago with 0 downloads. So by default we're still stuck with 2.1.0. To fix this, the first thing I did was to check what the ASP.NET web app templates use (they keep changing the defaults, so if you have an old project you're updating, it's always handy to check changes in default templates too).

The fix for me was removing the Version parameter from the tag in the .csproj file, as is now done in the default template. Original:

<ItemGroup>
   <PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
</ItemGroup>

After modification:

<ItemGroup>
   <PackageReference Include="Microsoft.AspNetCore.All" />
</ItemGroup>

This will essentially resolve to the latest installed version, i.e. 2.1.0 for now. Most likely 2.1.1 will be installed in the later updates. You could also try installing the latest package manually, but I recommend to resorting to default when possible. This way it's less likely that future updates will break my system.

Wibin
  • 198
  • 5
  • For now I got it solved by publishing `--self-contained`. However as the package ahs been updated (or at least downloaded 360 times by now) i will be trying to revert to a _non-self-contained_ publish... – Ropstah Jun 19 '18 at 09:44
  • Thank you so much. I just ran an `Update-Package` on my MVC Core 2.1.0 project, and all Core related packages got updated to 2.1.1. The only one that gave a problem (in dev) was `Microsoft.AspNetCore.All` and your solution to remove the version no. fixed it for me, without having to rely on playing catch-up with non-RTM daily builds. – ProfK Jun 19 '18 at 12:55
2

You have two options:

  1. Install the 2.1.1 framework on the server (as mentioned in another answer)

  2. Publish your app with all the required assets. You can do this with the following command:

    dotnet publish --self-contained
    
DavidG
  • 113,891
  • 12
  • 217
  • 223
  • Your second method worked perfectly. I went with the first. Thanks! – Ropstah Jun 19 '18 at 11:34
  • 1
    @Ropstah Make sure you don't install a preview version of the SDK on the server though, not sure the final release is available yet. – DavidG Jun 19 '18 at 13:08
  • can you elaborate on `the server`? ;) Just kidding, but it's a test server. However I obviously rather keep it running and install the final release when it's done, than having to do a re-install. That should not give any problems I'm guessing? – Ropstah Jun 19 '18 at 21:19
  • Well, it's beta quality software, so it's entirely up to you! The final version is currently being prepped by the .NET team, should be available in a few hours, maybe a day or so. I'm told its stuck... – DavidG Jun 19 '18 at 21:53