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

Open
opened 2026-01-29 16:30:23 +00:00 by claunia · 9 comments
Owner

Originally created by @smadarapu01 on GitHub (Jul 20, 2023).

Originally created by @smadarapu01 on GitHub (Jul 20, 2023).
Author
Owner

@nref commented on GitHub (Jul 20, 2023):

Yes, you'll need the dotnet runtime or you can build a self-contained app.

@nref commented on GitHub (Jul 20, 2023): Yes, you'll need the [dotnet runtime ](https://learn.microsoft.com/en-us/dotnet/core/install/linux) or you can build [a self-contained](https://learn.microsoft.com/en-us/dotnet/core/deploying/#publish-self-contained) app.
Author
Owner

@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

@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_**
Author
Owner

@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.

@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.
Author
Owner

@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?

@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?
Author
Owner

@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:

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
  </PropertyGroup>

then as @smadarapu01 said, you can pass the flags directly to msbuild. For example:

dotnet restore
dotnet msbuild HelloWorld.csproj /t:CreateRpm /p:TargetFramework=net6.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release /p:SelfContained=true /p:PublishSingleFile=true /p:PublishTrimmed=false /p:PublishDir=publish/linux-x64 /p:DebugSymbols=false /p:DebugType=None

If CreateRpm isn't available, you'll need to add a reference (directly or indirectly) to Packaging.Targets

    <PackageReference Include="Packaging.Targets" Version="0.1.220" />

and then do dotnet restore. Then the CreateRpm msbuild target will be available.

I noticed that you are targeting net7.0. You may want to use net6.0, because dotnet-packaging does 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-cache on a system that already has the runtime installed:

$ apt-cache depends dotnet-runtime-7.0
dotnet-runtime-7.0
  Depends: dotnet-hostfxr-7.0
  Depends: libicu70
  Depends: libc6
  Depends: libgcc-s1
  Depends: liblttng-ust1
  Depends: libssl3
  Depends: libstdc++6
  Depends: zlib1g

After having a look at the Deb targets, I knew what targets to change in my csproj:

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Packaging.Targets" Version="0.1.220" />
  </ItemGroup>

  <!-- Replace deps from Packaging.Targets; they're for net6.0 -->
  <ItemGroup>
    <DebDotNetDependencies Remove="@(DebDotNetDependencies)" />
  </ItemGroup>

  <ItemGroup Condition="'$(RuntimeIdentifier)' == ''">
    <DebDotNetDependencies Include="dotnet-runtime-7.0"/>
  </ItemGroup>

  <!-- Dependencies for self-contained net7.0 on linux-x64 -->
  <!-- Output of `apt-cache depends dotnet-runtime-7.0 on Ubuntu 22.04.1 -->
  <ItemGroup Condition="'$(RuntimeIdentifier)' != ''">
    <DebDotNetDependencies Include="libicu70"/>
    <DebDotNetDependencies Include="libc6"/>
    <DebDotNetDependencies Include="libgcc-s1"/>
    <DebDotNetDependencies Include="liblttng-ust1"/>
    <DebDotNetDependencies Include="libssl3"/>
    <DebDotNetDependencies Include="libstdc++6"/>
    <DebDotNetDependencies Include="zlib1g"/>
  </ItemGroup>

To do the same on an RPM-based distro, have a look at the the RPM targets, install dotnet-runtime-7.0 on an RPM-based machine, then use RPM-based commands to find out that package's dependencies.

@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: ```xml <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers> <SelfContained>true</SelfContained> <PublishSingleFile>true</PublishSingleFile> </PropertyGroup> ``` then as @smadarapu01 said, you can pass the flags directly to msbuild. For example: ``` dotnet restore dotnet msbuild HelloWorld.csproj /t:CreateRpm /p:TargetFramework=net6.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release /p:SelfContained=true /p:PublishSingleFile=true /p:PublishTrimmed=false /p:PublishDir=publish/linux-x64 /p:DebugSymbols=false /p:DebugType=None ``` If `CreateRpm` isn't available, you'll need to add a reference (directly or indirectly) to `Packaging.Targets` ```xml <PackageReference Include="Packaging.Targets" Version="0.1.220" /> ``` and then do `dotnet restore`. Then the `CreateRpm` msbuild target will be available. I noticed that you are targeting net7.0. You may want to use net6.0, because `dotnet-packaging` does 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-cache` on a system that already has the runtime installed: ``` $ apt-cache depends dotnet-runtime-7.0 dotnet-runtime-7.0 Depends: dotnet-hostfxr-7.0 Depends: libicu70 Depends: libc6 Depends: libgcc-s1 Depends: liblttng-ust1 Depends: libssl3 Depends: libstdc++6 Depends: zlib1g ``` After having a look at [the Deb targets](https://github.com/quamotion/dotnet-packaging/blob/3f7bd3c61a00ce2c51f4f53f34d149b0ce5f8fdd/Packaging.Targets/build/Packaging.Targets.targets#L174), I knew what targets to change in my csproj: ```xml <PropertyGroup> <TargetFramework>net7.0</TargetFramework> <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers> </PropertyGroup> <ItemGroup> <PackageReference Include="Packaging.Targets" Version="0.1.220" /> </ItemGroup> <!-- Replace deps from Packaging.Targets; they're for net6.0 --> <ItemGroup> <DebDotNetDependencies Remove="@(DebDotNetDependencies)" /> </ItemGroup> <ItemGroup Condition="'$(RuntimeIdentifier)' == ''"> <DebDotNetDependencies Include="dotnet-runtime-7.0"/> </ItemGroup> <!-- Dependencies for self-contained net7.0 on linux-x64 --> <!-- Output of `apt-cache depends dotnet-runtime-7.0 on Ubuntu 22.04.1 --> <ItemGroup Condition="'$(RuntimeIdentifier)' != ''"> <DebDotNetDependencies Include="libicu70"/> <DebDotNetDependencies Include="libc6"/> <DebDotNetDependencies Include="libgcc-s1"/> <DebDotNetDependencies Include="liblttng-ust1"/> <DebDotNetDependencies Include="libssl3"/> <DebDotNetDependencies Include="libstdc++6"/> <DebDotNetDependencies Include="zlib1g"/> </ItemGroup> ``` To do the same on an RPM-based distro, have a look at the [the RPM targets](https://github.com/quamotion/dotnet-packaging/blob/3f7bd3c61a00ce2c51f4f53f34d149b0ce5f8fdd/Packaging.Targets/build/Packaging.Targets.targets#L92), install `dotnet-runtime-7.0` on an RPM-based machine, then use RPM-based commands to find out that package's dependencies.
Author
Owner

@smadarapu01 commented on GitHub (Jul 27, 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:

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
  </PropertyGroup>

then as @smadarapu01 said, you can pass the flags directly to msbuild. For example:

dotnet restore
dotnet msbuild HelloWorld.csproj /t:CreateRpm /p:TargetFramework=net6.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release /p:SelfContained=true /p:PublishSingleFile=true /p:PublishTrimmed=false /p:PublishDir=publish/linux-x64 /p:DebugSymbols=false /p:DebugType=None

If CreateRpm isn't available, you'll need to add a reference (directly or indirectly) to Packaging.Targets

    <PackageReference Include="Packaging.Targets" Version="0.1.220" />

and then do dotnet restore. Then the CreateRpm msbuild target will be available.

I noticed that you are targeting net7.0. You may want to use net6.0, because dotnet-packaging does 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-cache on a system that already has the runtime installed:

$ apt-cache depends dotnet-runtime-7.0
dotnet-runtime-7.0
  Depends: dotnet-hostfxr-7.0
  Depends: libicu70
  Depends: libc6
  Depends: libgcc-s1
  Depends: liblttng-ust1
  Depends: libssl3
  Depends: libstdc++6
  Depends: zlib1g

After having a look at the Deb targets, I knew what targets to change in my csproj:

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Packaging.Targets" Version="0.1.220" />
  </ItemGroup>

  <!-- Replace deps from Packaging.Targets; they're for net6.0 -->
  <ItemGroup>
    <DebDotNetDependencies Remove="@(DebDotNetDependencies)" />
  </ItemGroup>

  <ItemGroup Condition="'$(RuntimeIdentifier)' == ''">
    <DebDotNetDependencies Include="dotnet-runtime-7.0"/>
  </ItemGroup>

  <!-- Dependencies for self-contained net7.0 on linux-x64 -->
  <!-- Output of `apt-cache depends dotnet-runtime-7.0 on Ubuntu 22.04.1 -->
  <ItemGroup Condition="'$(RuntimeIdentifier)' != ''">
    <DebDotNetDependencies Include="libicu70"/>
    <DebDotNetDependencies Include="libc6"/>
    <DebDotNetDependencies Include="libgcc-s1"/>
    <DebDotNetDependencies Include="liblttng-ust1"/>
    <DebDotNetDependencies Include="libssl3"/>
    <DebDotNetDependencies Include="libstdc++6"/>
    <DebDotNetDependencies Include="zlib1g"/>
  </ItemGroup>

To do the same on an RPM-based distro, have a look at the the RPM targets, install dotnet-runtime-7.0 on an RPM-based machine, then use RPM-based commands to find out that package's dependencies.

@smadarapu01 commented on GitHub (Jul 27, 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: > > ``` > <PropertyGroup> > <TargetFramework>net6.0</TargetFramework> > <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers> > <SelfContained>true</SelfContained> > <PublishSingleFile>true</PublishSingleFile> > </PropertyGroup> > ``` > > then as @smadarapu01 said, you can pass the flags directly to msbuild. For example: > > ``` > dotnet restore > dotnet msbuild HelloWorld.csproj /t:CreateRpm /p:TargetFramework=net6.0 /p:RuntimeIdentifier=linux-x64 /p:Configuration=Release /p:SelfContained=true /p:PublishSingleFile=true /p:PublishTrimmed=false /p:PublishDir=publish/linux-x64 /p:DebugSymbols=false /p:DebugType=None > ``` > > If `CreateRpm` isn't available, you'll need to add a reference (directly or indirectly) to `Packaging.Targets` > > ``` > <PackageReference Include="Packaging.Targets" Version="0.1.220" /> > ``` > > and then do `dotnet restore`. Then the `CreateRpm` msbuild target will be available. > > I noticed that you are targeting net7.0. You may want to use net6.0, because `dotnet-packaging` does 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-cache` on a system that already has the runtime installed: > > ``` > $ apt-cache depends dotnet-runtime-7.0 > dotnet-runtime-7.0 > Depends: dotnet-hostfxr-7.0 > Depends: libicu70 > Depends: libc6 > Depends: libgcc-s1 > Depends: liblttng-ust1 > Depends: libssl3 > Depends: libstdc++6 > Depends: zlib1g > ``` > > After having a look at [the Deb targets](https://github.com/quamotion/dotnet-packaging/blob/3f7bd3c61a00ce2c51f4f53f34d149b0ce5f8fdd/Packaging.Targets/build/Packaging.Targets.targets#L174), I knew what targets to change in my csproj: > > ``` > <PropertyGroup> > <TargetFramework>net7.0</TargetFramework> > <RuntimeIdentifiers>linux-x64</RuntimeIdentifiers> > </PropertyGroup> > > <ItemGroup> > <PackageReference Include="Packaging.Targets" Version="0.1.220" /> > </ItemGroup> > > <!-- Replace deps from Packaging.Targets; they're for net6.0 --> > <ItemGroup> > <DebDotNetDependencies Remove="@(DebDotNetDependencies)" /> > </ItemGroup> > > <ItemGroup Condition="'$(RuntimeIdentifier)' == ''"> > <DebDotNetDependencies Include="dotnet-runtime-7.0"/> > </ItemGroup> > > <!-- Dependencies for self-contained net7.0 on linux-x64 --> > <!-- Output of `apt-cache depends dotnet-runtime-7.0 on Ubuntu 22.04.1 --> > <ItemGroup Condition="'$(RuntimeIdentifier)' != ''"> > <DebDotNetDependencies Include="libicu70"/> > <DebDotNetDependencies Include="libc6"/> > <DebDotNetDependencies Include="libgcc-s1"/> > <DebDotNetDependencies Include="liblttng-ust1"/> > <DebDotNetDependencies Include="libssl3"/> > <DebDotNetDependencies Include="libstdc++6"/> > <DebDotNetDependencies Include="zlib1g"/> > </ItemGroup> > ``` > > To do the same on an RPM-based distro, have a look at the [the RPM targets](https://github.com/quamotion/dotnet-packaging/blob/3f7bd3c61a00ce2c51f4f53f34d149b0ce5f8fdd/Packaging.Targets/build/Packaging.Targets.targets#L92), install `dotnet-runtime-7.0` on an RPM-based machine, then use RPM-based commands to find out that package's dependencies.
Author
Owner

@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

@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
Author
Owner

@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.dll and libhostfxr.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 require dotnet-runtime-7.0 package to run.

@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.dll` and `libhostfxr.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 require `dotnet-runtime-7.0` package to run.
Author
Owner

@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

@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`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/dotnet-packaging#138