Can't run .NET Core 2.1(.1) application on Windows Server 2016 - asp.net-core

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.

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

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.

You have two options:
Install the 2.1.1 framework on the server (as mentioned in another answer)
Publish your app with all the required assets. You can do this with the following command:
dotnet publish --self-contained

Related

How to enforce specific package version on sub-dependency for netstandard library

I am building a netstandard2.0, with a series of sub-dependencies, including Azure.Data.Tables. I have found that Azure.Data.Tables on >=12.3.0 is not compatible with 2.2 projects, but version 12.0.0 is (or at least it doesn't crash my .Net Core 2.2 application).
Based on these premises the resolution was simple: put version 12.0.0 in the netstandard library dependencies. There's only one problem, that when I install this library using Visual Studio into my Net Core 2.2 project I get that visual studio decides to install 12.3.0.
I have checked documentation around enforcing certain versions using the allowed wildcards(https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#version-ranges-and-wildcards), such as:
<PackageReference Include="Azure.Data.Tables" Version="[12.0.0]" />
Which produces this package description just before pressing "install".
But it doens't seem to work, Visual Studio simply carries on with the 12.3.0 installation.
It turns out Visual Studio was just using the nuget cache for my locally generated packages. If I either changed the version of the packaged package then the sub-dependencies would change. As well, another way of getting the precise package would be to clear nuget's cache locally: nuget locals all -clear.

After moving .NET Core 2.2 web application to new computer with Windows 10, it fails

After moving the application I get this error. I have downloaded and installed SDK 3.1.302 and runtime 3.1.6 but I get this error:
HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Specific error detected by ANCM:
It was not possible to find any compatible framework version The framework 'Microsoft.AspNetCore.App', version '2.2.0' was not found. - The following frameworks were found: 2.1.20 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] 3.1.6 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] You can resolve the problem by installing the specified framework and/or SDK. The specified framework can be found at: - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=2.2.0&arch=x64&rid=win10-x64
On the SDK .net core download page it says 2.2 is no longer supported and so I downloaded. 3.1.302 as recommended.
However, I think I need to find somewhere in my VS 2019 for that solution and change it to 3.1.6 runtime from 2.2 but I have no idea where that would be.
I looked on the web for a solution but could not find one. I found a mention of removing this
environment variable but that didn't work.
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
Where is my app referencing .net core 2.2? It worked so well on Windows 7 Visual Studio 2017 that I moved it from.
Under project csproj file configuration you have something like <RuntimeFrameworkVersion>2.2</RuntimeFrameworkVersion> or <TargetFramework>netcoreapp2.2</TargetFramework> or <PackageReference Include="Microsoft.AspNetCore.All" Version="2.2" />?
And 2.2 is no longer supported you need back to 2.1 or 3.x. I suggest you to upgrade project to latest version if is it possible.
or you can still download the SDK 2.2 from archive.
https://dotnet.microsoft.com/download/dotnet-core
Installing .Net Core 3.1 does not install the older runtimes by default. You will need to install 2.2, or when you publish your program, publish it as "Self-contained" which should include everything needed to run it.
While 2.2 has been EOLed, you can still run your .net core 2.2 program. You can download the last 2.2 runtime here: https://dotnet.microsoft.com/download/dotnet-core/2.2
You will likely want the Windows Hosting Bundle.
Install that, and once it's complete, you can check your runtime version from powershell with dotnet --list-runtimes
You should see a list of installed runtimes come up. You will want to see something like: Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
With that you should be able to run the application.
That being said, I would also recommend updating to 3.1 as soon as possible.

missing "System" reference on ubuntu and .net core 3.0

I'm trying to develop a simple web app using .Net Core 3.0 on an Ubuntu machine.
I setup the .Net Core SDK and the runtime from this link. I setup VS Code and then I create a project using the following commands dotnet new webapp -o RazorPagesMovie code -r RazorPagesMovie
I built the project and it is working. But in VS Code, it shows the following error:
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
screenshot of vs code
Regarding your problem, there are multiple open issues on omnisharp-vscode (e.g. 3289, 3290) GitHub repository. A few workarounds are available as follows:
For Windows: install Visual Studio 2019 Community Edition, or MsBuild Tools 2019
For Linux/MacOS: install Mono 6.0.0 or newer
Or uninstall the previous versions of .NET Core. If you don't like these workarounds, the best solution to fix the issue is that installing the new (beta) OmniSharp build for the time being.
You can install this build by adding the following line into your VS Code settings.json:
"omnisharp.path": "1.34.4-beta.7"
Once you save the settings, the new build of omnisharp-vscode with fix will be installed. After the installation, restart IDE if required. I can confirm that the fix works for Windows.
I often get a similar message on .net core 2.x and I find that you have to add the reference to netstandard into the project file to fix as below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
..
</PropertyGroup>
<ItemGroup>
..
</ItemGroup>
<ItemGroup> <Reference Include="netstandard" /> </ItemGroup>
</Project>
On Mac I tried removing old dot net runtimes and sdks, using the preview version of omnisharp and verifying mono version above 6.0.0
I also deleted project bin and obj dirs, recompiled, deleted nuget cache dirs and restored.
Then I ran across this in related post:
ACK! Upgrading to Mono 6.4 solves problem under Linux!
(Under Mono 6.0 problem occurs as I have had this version before)
Not 6.0 necessarily....

How to list all installed NuGet Packages and Versions using .NET CLI

How to list all locally installed NuGet packages using .NET Core CLI in a ASP.NET Core project without Visual Studio 2017?
I have a ASP.NET Core 2.1 project. I have a <PackageReference Include="Microsoft.AspNetCore.App" /> by default that don't have a Version in it. I'd like to know what's the Version it used. I can't find any CLI command to query that information.
If Version attribute for metapackage (which Microsoft.AspNetCore.Appis) is not supplied, the lowest locally installed version is taken. You can check which versions you have installed locally in %userprofile%\.nuget\packages\microsoft.aspnetcore.app
However, you usually don't want to know metapackage version, but a version of each package in it and you can determine them by:
var referencedAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
foreach (var assembly in referencedAssemblies)
Console.WriteLine($"{assembly.Name} {assembly.Version}");

The specified framework 'Microsoft.AspNetCore.App', version '2.1.0' was not found

I tried to upgrade my web app from .net core 2.0 to .net core 2.1
I did:
1) Install Visual Studio Professional 2017 Preview Version 15.8.0 Preview 1.1
2) Installed the .net core 2.1.3 RC1 SDK from here: https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-rc1
3) Updated all of my aspnetcore nuget packages to the latest version.
After doing both of these things, when I start my project I get this screen:
HTTP Error 502.5 - Process Failure Common causes of this issue:
The application process failed to start
The application process started but then stopped
The application process started but failed to listen on the configured port
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit:
https://go.microsoft.com/fwlink/?LinkID=808681
and in my Output window from ASP.NET Core Web Server, I get this:
The specified framework 'Microsoft.AspNetCore.App', version '2.1.0' 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-preview2-final at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
2.1.0-rc1-final at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.0' 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-preview2-final at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
2.1.0-rc1-final at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
.NET Core 2.1 SDK will be released this week. If you can't wait until then, add this to your *.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RestoreAdditionalProjectSources>
https://dotnetfeed.blob.core.windows.net/orchestrated-release-2-1/20180515-07/final/index.json
</RestoreAdditionalProjectSources>
</PropertyGroup>
....
</Project>
And download the final SDK from: https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.1.300/dotnet-sdk-2.1.300-win-x64.exe
For more details visit: https://github.com/aspnet/Home/wiki/2.1.0-Early-Access-Downloads
By updating all NuGet packages, you seem to have upgraded from the RC version you started out with (which is installed on your system) to the RTM version currently being released (and thus already available on NuGet but not installed on your system).
The Microsoft.AspNetCore.App NuGet packages are supposed to be referenced without a version so that the installed tooling can pick an appropriate version.
Update your .csproj file to remove the Version attribute and only reference that package through:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
.NET Core SDK 2.1.300 is now available: https://www.microsoft.com/net/download/windows Install it, this fixed the problem for me.
Looks like it's available on chocolatey now https://chocolatey.org/packages/dotnetcore-sdk/2.1.300
Not yet on the normal dotnet distribution sites. Crazy.
uninstall previous version
Download and install version 2.1 sdk
After the whole process reboot your PC
It should work.
I opened the Visual Studio installer, went to Individual Components, selected .NET Core 2.1 Runtime (LTS), and installed it.
Solved my problem.