uno.toolkit.ui icon indicating copy to clipboard operation
uno.toolkit.ui copied to clipboard

Can build Uno targeting windows, linux and wasm when referencing Uno.Toolkit.Skia.WinUI

Open KWodarczyk opened this issue 1 year ago • 2 comments

Current behavior

Docker image fails to build wit the following errors:

[build 7/7] RUN dotnet publish UnoShadowContainer/UnoShadowContainer.csproj -c Release -f net8.0-browserwasm -o /app/uno-publish: 4.231 Determining projects to restore... 40.90 Restored /src/UnoShadowContainer/UnoShadowContainer.csproj (in 35.97 sec). 50.60 Downloading dotnet-runtime-wasm-linux-498e18e-7331dcb60e0-8790049905-Release-simd to /tmp/dotnet-runtime-wasm-linux-498e18e-7331dcb60e0-8790049905-Release-simd.zip 71.06 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : System.NotSupportedException: Failed to install emscripten [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 71.06 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.ValidateEmscripten() in //src/Uno.Wasm.Bootstrap/ShellTask.cs:line 1354 [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 71.06 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.RunPackager() in //src/Uno.Wasm.Bootstrap/ShellTask.cs:line 809 [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 71.06 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.Execute() in /_/src/Uno.Wasm.Bootstrap/ShellTask.cs:line 270 [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm]

Docker file:

# Use the .NET SDK image to build the application
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /src

# Copy the solution file and project files
COPY *.sln .
COPY UnoShadowContainer/*.csproj ./UnoShadowContainer/

RUN dotnet restore

# Copy the rest of the source code
COPY . .

# Build the Uno WebAssembly project
RUN dotnet publish UnoShadowContainer/UnoShadowContainer.csproj -c Release -f net8.0-browserwasm -o /app/uno-publish

# Build the runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish .

# Copy the Uno WebAssembly files to wwwroot
COPY --from=build /app/uno-publish/wwwroot ./wwwroot

# Expose port 80
EXPOSE 80

ENTRYPOINT ["dotnet", "UnoShadowContainer.dll"]

Expected behavior

Docker image should jus build successfully

How to reproduce it (as minimally and precisely as possible)

Create default uno application, add

  <ItemGroup>
      <PackageReference Include="Uno.Toolkit.Skia.WinUI" Version="6.1.8" />
  </ItemGroup>

in .csproj so it should look like this:

<Project Sdk="Uno.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net8.0-windows10.0.19041;net8.0-browserwasm;net8.0-desktop</TargetFrameworks>

    <OutputType>Exe</OutputType>
    <UnoSingleProject>true</UnoSingleProject>

    <!-- Display name -->
    <ApplicationTitle>UnoShadowContainer</ApplicationTitle>
    <!-- App Identifier -->
    <ApplicationId>com.companyname.UnoShadowContainer</ApplicationId>
    <!-- Versions -->
    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
    <ApplicationVersion>1</ApplicationVersion>
    <!-- Package Publisher -->
    <ApplicationPublisher>Administrator</ApplicationPublisher>
    <!-- Package Description -->
    <Description>UnoShadowContainer powered by Uno Platform.</Description>
    <!--
      If you encounter this error message:

        error NETSDK1148: A referenced assembly was compiled using a newer version of Microsoft.Windows.SDK.NET.dll.
        Please update to a newer .NET SDK in order to reference this assembly.

      This means that the two packages below must be aligned with the "build" version number of
      the "Microsoft.Windows.SDK.BuildTools" package above, and the "revision" version number
      must be the highest found in https://www.nuget.org/packages/Microsoft.Windows.SDK.NET.Ref.
    -->
    <!-- <WindowsSdkPackageVersion>10.0.22621.28</WindowsSdkPackageVersion> -->

    <!--
      UnoFeatures let's you quickly add and manage implicit package references based on the features you want to use.
      https://aka.platform.uno/singleproject-features
    -->
    <UnoFeatures>
      Lottie;
      Hosting;
      Toolkit;
      Logging;
      Mvvm;
      Configuration;
      Http;
      Serialization;
      Localization;
      Navigation;
      ThemeService;
    </UnoFeatures>
  </PropertyGroup>

  <ItemGroup>
      <PackageReference Include="Uno.Toolkit.Skia.WinUI" Version="6.1.8" />
  </ItemGroup>

</Project>

UnoShadowContainer.zip

use the docker file above and try to build an image: docker build -t shadow .

Nuget Package:

Package Version(s):

Affected platform(s):

  • [ ] WebAssembly

IDE:

  • [ ] Visual Studio 2022

Relevant plugins:

Anything else we need to know?

It works fine when building on windows or linux but fails when building in docker. Perhaps there there needs to be something installed in docker e.g emscripten ?

KWodarczyk avatar Sep 12 '24 09:09 KWodarczyk

@KWodarczyk would you be able to add the /bl switch to your dotnet build command? That way it will generate a .binlog file that will have more information for us to diagnose

https://platform.uno/docs/articles/uno-builds-troubleshooting.html#from-the-command-line

kazo0 avatar Sep 12 '24 11:09 kazo0

artifacts.zip

Attaching a zip file that contains the .binlog

KWodarczyk avatar Sep 12 '24 14:09 KWodarczyk

You need to install python. Image

When diagnosing these issues, you can open the binlog to get more information.

Note that python install will not be needed anymore when moving to net9.

jeromelaban avatar Oct 01 '24 16:10 jeromelaban

@jeromelaban so in order to use Uno.Toolkit we need to have python installed ?

KWodarczyk avatar Oct 01 '24 16:10 KWodarczyk

@jeromelaban

I have added python installation to my docker file:

# Install Python RUN apt-get update && apt-get install -y python3 python3-pip && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*

but now there is different error:

RUN dotnet publish UnoShadowContainer/UnoShadowContainer.csproj -c Release -f net8.0-browserwasm -o /app/uno-publish: 2.460 Determining projects to restore... 68.25 Restored /src/UnoShadowContainer/UnoShadowContainer.csproj (in 1.09 min). 76.75 /src/UnoShadowContainer/obj/Release/net8.0-browserwasm/Uno.UI.SourceGenerators/Uno.UI.SourceGenerators.XamlGenerator.XamlCodeGenerator/MainPage_aebbdba941c6c90bc6bcbebbf05bedd1.cs(223,11): warning Uno0001: Microsoft.UI.Xaml.Media.RadialGradientBrush.GradientOrigin is not implemented in Uno (https://aka.platform.uno/notimplemented?m=Microsoft.UI.Xaml.Media.RadialGradientBrush.GradientOrigin) (https://aka.platform.uno/notimplemented) [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 77.44 Downloading dotnet-runtime-wasm-linux-498e18e-7331dcb60e0-8790049905-Release-simd to /tmp/dotnet-runtime-wasm-linux-498e18e-7331dcb60e0-8790049905-Release-simd.zip 146.2 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'ninja' with working directory '/src/UnoShadowContainer/obj/Release/net8.0-browserwasm/workAot'. No such file or directory [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 146.2 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 146.2 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 146.2 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.RunProcess(String executable, String parameters, String workingDirectory, ValueTuple`2[] environmentVariables) in //src/Uno.Wasm.Bootstrap/ShellTask.cs:line 664 [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 146.2 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.RunPackager() in //src/Uno.Wasm.Bootstrap/ShellTask.cs:line 977 [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm] 146.2 /root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): error : at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.Execute() in /_/src/Uno.Wasm.Bootstrap/ShellTask.cs:line 270 [/src/UnoShadowContainer/UnoShadowContainer.csproj::TargetFramework=net8.0-browserwasm]

Dockerfile:27

25 | # (echo "Build failed. Check the binlog for details." && mkdir -p /app/uno-publish && touch /app/uno-publish/BUILD_FAILED) 26 | 27 | >>> RUN dotnet publish UnoShadowContainer/UnoShadowContainer.csproj -c Release -f net8.0-browserwasm -o /app/uno-publish 28 | 29 |

ERROR: failed to solve: process "/bin/sh -c dotnet publish UnoShadowContain artifacts.zip

binlog error:

/root/.nuget/packages/uno.wasm.bootstrap/8.0.21/build/Uno.Wasm.Bootstrap.targets(226,3): System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'ninja' with working directory '/src/UnoShadowContainer/obj/Release/net8.0-browserwasm/workAot'. No such file or directory at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.RunProcess(String executable, String parameters, String workingDirectory, ValueTuple`2[] environmentVariables) in //src/Uno.Wasm.Bootstrap/ShellTask.cs:line 664 at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.RunPackager() in //src/Uno.Wasm.Bootstrap/ShellTask.cs:line 977 at Uno.Wasm.Bootstrap.ShellTask_v038af955a9b67691b2e0a0ec4ebf87820919b6b1.Execute() in /_/src/Uno.Wasm.Bootstrap/ShellTask.cs:line 270 [/src/UnoShadowContainer/UnoShadowContainer.csproj]

logs attached

KWodarczyk avatar Oct 02 '24 12:10 KWodarczyk

Thanks, make sure to look at all the dependencies that need to be added when building.

The error message tells what's missing (ninja in this case).

jeromelaban avatar Oct 02 '24 12:10 jeromelaban

@jeromelaban will look at it but, looks like i needed to install python, now ninja and all this just because i am adding Uno.Toolkit.Skia.WinU to my project, is this expected ? does skia require those things ?

KWodarczyk avatar Oct 02 '24 13:10 KWodarczyk