mirror of
https://github.com/quamotion/dotnet-packaging.git
synced 2026-02-13 21:30:41 +00:00
Question: Do we need to install .netCore 6.0/7.0 runtime or SDK in linux server to run a rpm which created from .netCore 6.0/7.0 #138
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @smadarapu01 on GitHub (Jul 20, 2023).
@nref commented on GitHub (Jul 20, 2023):
Yes, you'll need the dotnet runtime or you can build a self-contained app.
@smadarapu01 commented on GitHub (Jul 24, 2023):
I am creating a rpm with as below command, so its self contained application isn't it?
dotnet msbuild TestService.csproj /t:Clean,CreateRpm /p:TargetFramework=net7.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release /p:PublishSingleFile=true /p:DebugSymbols=false /p:DebugType=None /p:version=22.1.100
@atauenis commented on GitHub (Jul 24, 2023):
The presence or absence of .NET Runtime files together with application package (is the application self-contained or not) is configured via
<SelfContained>True</SelfContained>or<SelfContained>False</SelfContained>inside a<PropertyGroup>section of CSPROJ file.@smadarapu01 commented on GitHub (Jul 25, 2023):
SelfContained is not available in CSPROJ, but rpm is running in linux box and there is no .NET Runtime installed in Linux server, how it can run?
@nref commented on GitHub (Jul 25, 2023):
What do you mean that "SelfContained is not available in CSPROJ"?
If you cannot install the dotnet runtime on your Linux server, and if you can't add something like this to your .csproj:
then as @smadarapu01 said, you can pass the flags directly to msbuild. For example:
If
CreateRpmisn't available, you'll need to add a reference (directly or indirectly) toPackaging.Targetsand then do
dotnet restore. Then theCreateRpmmsbuild target will be available.I noticed that you are targeting net7.0. You may want to use net6.0, because
dotnet-packagingdoes not yet support net7.0 (indeed, this project appears to be abandoned). However, I was able to make net7.0 self-contained work on Ubuntu 22.04 with some extra work:First, realize conceptually that even self-contained builds have some dependencies on the system they're running on. These typically provided by your distro's package manager, and you can ask that package manager what they are.
I've only gone through with this on Ubuntu where you can discover them with
apt-cacheon a system that already has the runtime installed:After having a look at the Deb targets, I knew what targets to change in my csproj:
To do the same on an RPM-based distro, have a look at the the RPM targets, install
dotnet-runtime-7.0on an RPM-based machine, then use RPM-based commands to find out that package's dependencies.@smadarapu01 commented on GitHub (Jul 27, 2023):
@smadarapu01 commented on GitHub (Jul 27, 2023):
1.We have a .Net Core application which we are deploying without installing the prereq of .Net Runtime explicitly in a Linux box. The app runs without any issues so we are wondering how is the .Net run time getting installed in the Linux box
2. This .NET Core application creates rpm using dotnet msbuild TestService.csproj /t:Clean,CreateRpm /p:TargetFramework=net7.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release /p:PublishSingleFile=true /p:DebugSymbols=false /p:DebugType=None /p:version=22.1.100
3. This .NetCore application CSPROJ SelfContained is not avaiable
Can you please reply me, how it runs in linux server
@atauenis commented on GitHub (Jul 31, 2023):
If the RPM is containing a lot of DLL & SO files (about 60 MB), named like
System.Linq.dllandlibhostfxr.so, the app is self contained and do not require installation of .NET Runtime. If the RPM is lightweight (containing mostly the compiled program without extra garbage), it will requiredotnet-runtime-7.0package to run.@nref commented on GitHub (Jul 31, 2023):
Right idea, but you do have the causality reversed.
If the app is self-contained, then your distribution will include external dependencies (.dll and .so files). Unless you also choose single-file deployment, in which case those files are embedded in the executable.
If the app is lightweight, then it will require
dotnet-runtime-7.0