unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.81k stars 708 forks source link

Desktop TFM Packaging Support #16440

Open jeromelaban opened 5 months ago

jeromelaban commented 5 months ago

What would you like to be added

Add support for publishing to different platform specific packages:

known issues

Why is this needed

No response

For which platform

No response

Anything else we need to know?

No response

Additional resources

ramezgerges commented 5 months ago

I would also suggest packaging for Flatpak. AppImages are pretty much on life support, so I'm not sure if it's worth the effort.

jeromelaban commented 5 months ago

If anyone is tracking this issue, I've added some links to known macOS and Linux packaging samples in the original post.

TopperDEL commented 4 months ago

If anyone is tracking this issue, I've added some links to known macOS and Linux packaging samples in the original post.

This is not working for my app. I've added the Dotnet.Bundle-Nuget to my Uno-Project (single project, Uno 5.2). Then I tried building it with this command: dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=net8.0-desktop

It states The target BundleApp does not exist in the project. According to this issue I also tried adding a TargetFramework-Parameter: dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=net8.0-desktop -p:TargetFramework=net8.0 This leads to the same error. Any hints?

ArchieCoder commented 4 months ago

@TopperDEL I had the same error as you.

I was able to make the command line ran successfully:

dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -p:TargetFramework=net8.0-desktop /p:CFBundleShortVersionString=1.0.0 -restore

Please let me know if it works. I have the publish folder, but I don't know what else to do with it.

TopperDEL commented 4 months ago

Hm, I get the error C:\Program Files\dotnet\sdk\8.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(117,5): error NETSDK1139: Der Zielplattformbezeichner "desktop" wurde nicht erkannt. (TargetFramework-name "desktop" not recognized) for all of my library projects.

TopperDEL commented 4 months ago

@jeromelaban May you clarifiy how bundeling for macOs could work? I would love to get a *.pkg for the net8.0-desktop targeting macOS.

ArchieCoder commented 4 months ago

@TopperDEL did you use the same line as me?

TopperDEL commented 4 months ago

Exactly the same, yes. But I have a quite huge solution already with many library-projects. May you add one library to your project and see if that works? This is a sample of a library that crashed with the above "desktop not recognized"-error:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MvvmGen"/>
    <PackageReference Include="SharpHash"/>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\myapp.Contracts\myapp.Contracts.csproj" />
    <ProjectReference Include="..\myapp.Services\myapp.Services.csproj" />
  </ItemGroup>
</Project>
jeromelaban commented 4 months ago

Hm, I get the error C:\Program Files\dotnet\sdk\8.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(117,5): error NETSDK1139: Der Zielplattformbezeichner "desktop" wurde nicht erkannt. (TargetFramework-name "desktop" not recognized) for all of my library projects.

This generally means that the Sdk specified at the root of the csprojs is not Uno.Sdk.

@jeromelaban May you clarifiy how bundeling for macOs could work? I would love to get a *.pkg for the net8.0-desktop targeting macOS.

It's not defined at this point, but intuitively, dotnet publish would generate a .pkg or a .app.

TopperDEL commented 4 months ago

Hm, I get the error C:\Program Files\dotnet\sdk\8.0.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(117,5): error NETSDK1139: Der Zielplattformbezeichner "desktop" wurde nicht erkannt. (TargetFramework-name "desktop" not recognized) for all of my library projects.

This generally means that the Sdk specified at the root of the csprojs is not Uno.Sdk.

Are class libraries meant to also use Uno.Sdk?

@jeromelaban May you clarifiy how bundeling for macOs could work? I would love to get a *.pkg for the net8.0-desktop targeting macOS.

It's not defined at this point, but intuitively, dotnet publish would generate a .pkg or a .app.

Who is in charge to define this? Is this a Microsoft-thing?

jeromelaban commented 4 months ago

Are class libraries meant to also use Uno.Sdk?

If you want to use Uno in this class library, yes.

Who is in charge to define this? Is this a Microsoft-thing?

It will be an Uno Platform feature.

TopperDEL commented 4 months ago

So a "normal" class-library (containing only C#-code) does not need to Reference the Uno.Sdk. Hm. Still wondering where this error comes from then.

I'm looking forward to have the PKG/APP-support. Thanks for your awesome work!

jeromelaban commented 4 months ago

So a "normal" class-library (containing only C#-code) does not need to Reference the Uno.Sdk. Hm. Still wondering where this error comes from then.

Normal class libraries should not be showing this error. If you can repro that specific behavior, please open an issue with more details. Thanks!