I have some problem with deploy simple .Net core console application to linux server.
I\'ve created simple console Hello world application this way:
--self-contained
means that you dont need to have installed .Net Core on your target machine because all of the needed components are in the release folder
Second thing is duplicating parameters because -r debian.8-x64
setting to true --self-contained
(in other words you dont need --self-contained
after you set a runtime identifier)
Finally try dotnet restore
before publish. Then make sure you copying right thing from ./bin/[configuration]/[framework]/[runtime]
( ./bin/[configuration]/[framework]/
is for a framework-dependent deployment). You can even set output folder manually by parameter -o
(for example dotnet publish -c release -r debian.8-x64 -o copyme
and copy copyme
to your "linux server")
You may want to check out dotnet-packaging as well. It includes a dotnet deb
command line utility which allows you to create a .deb
file (i.e. a Debian installer) which you can use to install your app on Debian. It should make deployment easier for you.
To get started, you'll first need to add this section to your .csproj
file:
<ItemGroup>
<PackageReference Include="Packaging.Targets" Version="0.1.45" />
<DotNetCliToolReference Include="dotnet-deb" Version="0.1.45" />
<ItemGroup>
Then, run dotnet restore
and dotnet deb -c Release -r debian.8-x64 -f netcoreapp2.0
. This will create a .deb
file you can use to deploy your application to Debian.
You are copying the wrong stuff for deployment. When you dotnet publish
, you should use the contents of the publish
dir. For your case, it should be release/netcoreapp2.0/debian.8-x64/publish/
.
If you use the non-publish directory (release/netcoreapp2.0/debian.8-x64/
), it will assume you want to run your project in development mode, and expects to use assets from the local nuget cache, which will most likely be missing on your deployment machine.
FWIW, you are doing a few things very strangely. First, you need to decide if you want to really use self-contained deployments or not. If you are, you dont even need dotnet installed on the machine you are trying to deploy on.