Open rolfbjarne opened 2 years ago
What is workaround for that?
1) If you enable trimming - compile error: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.
2) If you disable trimming - macOS projects must build with PublishTrimmed=true. Current value: false. Set 'LinkMode=None' instead to disable trimming for all assemblies.
3) If add <LinkMode>None</LinkMode>
in csproj - I have error from first point
What is the right way to use it?
I don't care about app size. How can I just disable it or make it work?
.NET 7 + Empty project with signalr client
<PropertyGroup>
<TargetFramework>net7.0-macos</TargetFramework>
<OutputType>Exe</OutputType>
<ApplicationId>hidden</ApplicationId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>
cc @rolfbjarne
- If you enable trimming - compile error: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.
The fix is to investigate the compile error here. I tried creating a csproj with the signalr client and it built fine for me.
Can you get a binlog as described here: https://github.com/xamarin/xamarin-macios/wiki/Diagnosis#binary-build-logs?
@rolfbjarne
this is demo repository: https://github.com/Romfos/test-dotent-macos
error: https://github.com/Romfos/test-dotent-macos/actions/runs/5749135585/job/15583371765
This is the error:
error MM0179: This version of Microsoft.macOS requires the macOS 13.3 SDK (shipped with Xcode 14.3). Either upgrade Xcode to get the required header files or use the dynamic registrar or set the managed linker behaviour to Link Platform or Link Framework SDKs Only in your project's Mac Build Options > Linker Behavior) (to try to avoid the new APIs).
The easiest way to fix this is to use a newer Xcode (14.3 in this case).
@rolfbjarne
wow
thank you, it helped me
on: push
jobs:
build:
runs-on: macos-13
steps:
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Check out repository
uses: actions/checkout@v3
- name: Install macos workload
run: dotnet workload install macos
- name: Build osx-x64
run: dotnet publish -r osx-x64 ./MacAppSignalR/MacAppSignalR.csproj
probably we need a guide - how to make it work with github actions
just make runs-on: macos-13
+ dotnet workload install macos
are not always enough
but still strange that it tells me: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.
I've filed a dotnet/runtime issue for this: https://github.com/dotnet/runtime/issues/90607
The second message:
"Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false."
has been reworded, so it now only says:
"Optimizing assemblies for size failed."
and thus this is at least partially done. Moving to .NET 9 for the first message.
A few linker messages are confusing:
"Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink": https://github.com/dotnet/sdk/blob/93d3792d1b22fef02b9e1faed67d8fc71ad344e9/src/Tasks/Common/Resources/Strings.resx#L513: This is shown even if setting
TrimMode=copy
(i.e. not optimizing for size - which is the default for macOS apps), and it's confusing because it says the linker is optimizing for size when it really isn't. Ref: https://github.com/unoplatform/uno/pull/8986"Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.". https://github.com/dotnet/sdk/blob/93d3792d1b22fef02b9e1faed67d8fc71ad344e9/src/Tasks/Common/Resources/Strings.resx#L685: This is confusing because setting
PublishTrimmed
to false is not allowed for our projects: https://github.com/xamarin/xamarin-macios/blob/ab52bb2f454de65ca16211b37d8b4523cb1a97d1/dotnet/targets/Xamarin.Shared.Sdk.targets#L265-L269We should look into rewording/hiding these for our use-case.