quamotion / dotnet-packaging

Extensions for the .NET Core CLI which help packaging and publishing .NET Core applications
MIT License
653 stars 85 forks source link

.NET 7 and .NET 8 support #243

Open atauenis opened 11 months ago

atauenis commented 11 months ago

Hi, all. Found that dotnet-packaging utilities v0.1.220 does not working with .NET 7 and 8 SDKs.

First, they're requiring .NET 6.0 SDK to at least run, otherwise the message appear:

You can invoke the tool using the following command: dotnet-deb
Tool 'dotnet-deb' (version '0.1.220') was successfully installed.
You must install or update .NET to run this application.

App: /root/.dotnet/tools/dotnet-deb
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
.NET location: /usr/share/dotnet

The following frameworks were found:
  7.0.14 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  8.0.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Learn more:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=linux-x64&os=debian.12

With .NET SDK 6 installed, all net6.0-targeted apps are building and packaging well.

Second, if change TargetFramework to net8.0 or net7.0, the build breaks:

dotnet deb (0.1.220+3f7bd3c61a)
MSBuild version 17.7.1+971bf70db for .NET
/usr/share/dotnet/sdk/6.0.413/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0.  Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0.

Strange that MSBuild still looks for .NET SDK 6 by dotnet deb, but that's is. Plain dotnet publish is working correctly.

If try to set the framework version by command line (dotnet deb -c Release -f net8.0) other strange error appear:

error MSB4057: The target "CreateDeb" does not exist in the project.

If set multiple dotnet versions, <TargetFrameworks>net6.0;net7.0;net8.0</TargetFramework> all three are building, but only a build for .NET 6 gets packed to deb/rpm/zip, other two are ignored by dotnet-packaging.

Hope, the maintainer of the project will remember about it, and add support for newer .NET versions. :) Best regards.

atauenis commented 11 months ago

Fixed the MSB4057 error by removing Directory.Build.Props file in my project (where <PackageReference Include="Packaging.Targets"> was placed by NuGet), and keeping correct reference to latest NuGet package version in main csproj file (just adding the reference was not enough, seems, csproj conflicted with props file):

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

Now packages are correctly building by dotnet publish -c Release -r linux-x64 -t:CreateDeb,CreateRpm, dotnet publish -c Release -r win-x86 -t:CreateZip commands instead of dotnet deb, dotnet zip, etc. But the task successful. This is the workaround how to use dotnet-packaging in .NET 8 apps.

lancewynn commented 10 months ago

I am attempting to do the same, however I need to use the --self-contained true switch to be able to include the Dotnet8 runtimes. When doing this, the net6 runtime is included in the output. Has anyone found any work around for this scenario?

atauenis commented 10 months ago

Very strange, as for my project, it's working fine. Inspect webone.csproj and build-armv6.sh files. May be some ideas will became.

Also I've tried to build it using default build.sh with set <TargetFramework>net8.0</TargetFramework> in csproj, all binary files got produced with correct .NET 8 setup.

Mysame commented 6 months ago

Fixed the MSB4057 error by removing Directory.Build.Props file in my project (where <PackageReference Include="Packaging.Targets"> was placed by NuGet), and keeping correct reference to latest NuGet package version in main csproj file (just adding the reference was not enough, seems, csproj conflicted with props file):

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

Now packages are correctly building by dotnet publish -c Release -r linux-x64 -t:CreateDeb,CreateRpm, dotnet publish -c Release -r win-x86 -t:CreateZip commands instead of dotnet deb, dotnet zip, etc. But the task successful. This is the workaround how to use dotnet-packaging in .NET 8 apps.

Using this I can create a .deb file on net8 , however, it won't install on Debian 12 because it will have a dependency on libicu <70 & openssl <1.1

This does not correspond with what should be included in dotnet 8 (openssl 3 & libicu 73) https://learn.microsoft.com/en-us/dotnet/core/compatibility/containers/8.0/debian-version

So the tool requires an update, I'm guessing.

flozano commented 6 months ago

Also affected by this. It'd be great to be able to build RPMs with dotnet 8.0