I have a relatively simple .NET Core console app. It has no external dependencies. I build it using the following:
dotnet publish -c Release -r win10-x64
It generates a \bin\Release\netcoreapp2.2\win10-x64
folder structure. This folder contains the a number of files and a publish folder:
I copy this entire structure to a Windows Server 2016. According to the dotnet --list-runtimes
commands the server has the following runtimes installed:
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
However, when I run my .exe file (netcoreapp2.2\win10-x64\LayoutAutomation.exe
), I get the following error:
Error:
An assembly specified in the application dependencies manifest (LayoutAutomation.deps.json) was not found:
package: 'runtime.win-x64.Microsoft.NETCore.App', version: '2.2.0'
path: 'runtimes/win-x64/lib/netcoreapp2.2/Microsoft.CSharp.dll'
If I try to run the exe from the publish
folder (which seemingly has the entire .NET Core installation), it runs fine.
So how can I can't run the exe from the netcoreapp2.2\win10-x64
folder? The .NET Core is installed on the box - it should run.
The Publish command is one of the rare cases where Microsoft tools do what they claim to do—namely, publish the application to a specified location.
The files under the bin/release are compilation artifacts with local dependencies. Your server can't find the dependencies because those files are meant to be executed on your development machine. Those dependencies can be located in a variety of places and the compiler consolidates them in release folder.
The files under Publish are built for deployment, and depending on your publish settings, can be self-contained (default) or framework-dependent. You should copy the Publish folder's contents (or the entire folder) to your final deployment path. If you want to publish your application as framework-dependent, then modify your publish command like so:
dotnet publish -c Release -r win10-x64 --self-contained false
You can also add the -o
flag to specify a deployment path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With