-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add PublishAot flag gives package restore error using global.json #100929
Comments
Can you run Not sure how we're ending up trying to restore the linux-arm package. The .NET SDK knows such package doesn't exist. We're adding linux-arm for .NET 9, but a .NET 8 SDK (and a project targeting .NET 8) shouldn't be asking about it. Cc @ivanpovazan |
|
Since ios and linux-bionic runtime packs are still in preview (on nuget.org), I applied this patch with explicit version: --- a/PublishAotError/PublishAotError.csproj
+++ b/PublishAotError/PublishAotError.csproj
@@ -59,7 +59,7 @@
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
-<!-- <PackageReference Include="Microsoft.DotNet.ILCompiler" Version="8.0.4" />-->
+ <PackageReference Include="Microsoft.DotNet.ILCompiler;runtime.ios-arm64.Microsoft.DotNet.ILCompiler;runtime.linux-bionic-arm64.Microsoft.DotNet.ILCompiler" Version="8.0.0-preview.6.23329.7" /> and used Once we publish the stable versions of runtime packs, that will resolve the restore issue and align the ios/android targets so we don't need to specify the version-which-exist-in-nugetorg. |
@am11 does your workaround also work from Visual Studio? I am asking this because by just specifying |
Yes, this patch is enough without --- a/PublishAotError/PublishAotError.csproj
+++ b/PublishAotError/PublishAotError.csproj
@@ -19,6 +19,8 @@
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
+ <RuntimeIdentifier Condition="'$(TargetFramework)'=='net8.0-android'">linux-bionic-arm64</RuntimeIdentifier>
+ <RuntimeIdentifier Condition="'$(TargetFramework)'=='net8.0-ios'">ios-arm64</RuntimeIdentifier>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
@@ -30,7 +32,6 @@
<CreatePackage>true</CreatePackage>
<MtouchUseLlvm>true</MtouchUseLlvm>
<PublishAot>true</PublishAot>
- <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'"> VS for Mac is retiring on August 31, 2024 (in favor of DevKit+VSCode). I haven't installed it. :) |
Thank you @am11 @b12kab can you try the workaround suggested in #100929 (comment) to unblock you in your work? Nevertheless, I think we should investigate how we can avoid restoring packages for |
Agreed. It was also trying to restore |
It used to be that one always had to specify I wonder if the issue is with this logic. But also, this is essentially a crossbuild so maybe this should error out somewhere asking people to specify the RID manually. We might not be able to infer a good one. |
I've updated the sample adding the reference noted here, except to place it in an if enclosure that should only be picked up by an iOS release build, just like the PublishAot I should have put the command line build that I used which is: dotnet publish -f net8.0-ios -c Release I've uploaded the requested binlog Using the command line build, I get this error: PublishAotError -> /private/tmp/Projects/publishaotproblem/PublishAotError/bin/Release/net8.0-ios/ios-arm64/PublishAotError.dll |
@b12kab thank you for providing the binlog. Sorry for the confusion about the workarounds. Can you try the following:
|
|
Where is this version coming from? This is some very old pre-release version (it's a year old build). Can you delete any explicit ILCompiler package references you have in the project file, delete obj and bin directories, and run |
https://www.nuget.org/packages/runtime.ios-arm64.Microsoft.DotNet.ILCompiler#versions-body-tab
The confusing part is why is it calling .cmd script on macOS on that machine. Maybe something is off in |
Oh, I see, this version is in the project file: <ItemGroup Condition="$(TargetFramework.Contains('ios'))">
<PackageReference Include="Microsoft.DotNet.ILCompiler;runtime.ios-arm64.Microsoft.DotNet.ILCompiler;runtime.linux-bionic-arm64.Microsoft.DotNet.ILCompiler" Version="8.0.0-preview.6.23329.7" />
</ItemGroup> We don't ship |
Yeah it was either #100929 (comment) "or" #100929 (comment) (both fix the compilation error individually). The OP has applied both. |
Removing the additional nuget worked, but gets warnings (see below) with both commands:
What about removing the RuntimeIdentifier from the iOS conditional compile PropertyGroup allowed this to work? /private/tmp/publishaotproblem/PublishAotError/obj/Release/net8.0-ios/ios-arm64/linked/Microsoft.iOS.dll : warning IL3053: Assembly 'Microsoft.iOS' produced AOT analysis warnings. [/private/tmp/publishaotproblem/PublishAotError/PublishAotError.csproj::TargetFramework=net8.0-ios] |
This is enough, now that csproj has RuntimeIdentifier. When I collected the
That's a separate issue. Some warnings are ignorable others aren't, you would need to test the published app on the device/emulator to make sure whether or not it's safe to ignore these. In any case, those should be reported in their corresponding downstream repos (such as https://github.com/dotnet/maui/issues, if there isn't an issue already tracking it). |
@am11 Yes, please. I'm unsure if I can move the setting outside of the conditional compile, as the original project looks at the active configuration to choose between arm-ios64 and iossimulator-x64. Thank you all for your help. |
Could you show this error? |
Glad it worked and that you are able to build your app. Regarding your question:
If the runtime identifier is unknown during By specifying: <RuntimeIdentifier Condition="'$(TargetFramework)'=='net8.0-android'">linux-bionic-arm64</RuntimeIdentifier> we just tricked Your configuration for ios was correct, the problem is on our end with multi-targeting which you had to work around. Regarding the trim and AOT warnings that you get. They are indication that the MAUI framework and/or your app is not fully compatible with NativeAOT. As long as there are trim/AOT warnings during the build, there is no guarantee that the app will work correctly in all cases during runtime with NativeAOT. It might work, but it could also crash depending on the use case. |
@ivanpovazan, in the original repro, this is the error I received for net8.0-ios: % dotnet publish -f net8.0-ios
MSBuild version 17.9.6+a4ecab324 for .NET
Determining projects to restore...
/Users/am11/projects/publishaotproblem/PublishAotError/PublishAotError.csproj : error NU1103: Unable to find a stable package runtime.linux-arm.Microsoft.DotNet.ILCompiler with version (>= 8.0.3) [/Users/am11/projects/publishaotproblem/PublishAotError.sln]
/Users/am11/projects/publishaotproblem/PublishAotError/PublishAotError.csproj : error NU1103: - Found 411 version(s) in dotnet9 [ Nearest version: 9.0.0-alpha.1.24069.7 ] [/Users/am11/projects/publishaotproblem/PublishAotError.sln]
/Users/am11/projects/publishaotproblem/PublishAotError/PublishAotError.csproj : error NU1103: - Found 3 version(s) in nuget.org [ Nearest version: 9.0.0-preview.1.24080.9 ] [/Users/am11/projects/publishaotproblem/PublishAotError.sln]
/Users/am11/projects/publishaotproblem/PublishAotError/PublishAotError.csproj : error NU1103: - Found 0 version(s) in /usr/local/share/dotnet/library-packs [/Users/am11/projects/publishaotproblem/PublishAotError.sln]
/Users/am11/projects/publishaotproblem/PublishAotError/PublishAotError.csproj : error NU1103: - Found 0 version(s) in dotnet8 [/Users/am11/projects/publishaotproblem/PublishAotError.sln]
Failed to restore /Users/am11/projects/publishaotproblem/PublishAotError/PublishAotError.csproj (in 819 ms). That error is about linux-arm because nuget client searches for all runtime.json files, collects all entries in those files and tries to restore for all platforms matching the TPI https://github.com/NuGet/NuGet.Client/blob/95b79314dfece146ddcbac902111d9ff946cf514/src/NuGet.Core/NuGet.Commands/RestoreCommand/ProjectRestoreCommand.cs#L458. If you open runtime.json in https://nuget.info/packages/Microsoft.DotNet.ILCompiler/8.0.3, you will see linux-arm on line 15, which is wrong because that runtime does not exist. If i delete just that linux-arm block from |
Yes, looks like it. A linux-arm entry was added in dotnet/runtimelab#1530 last time ARM32 support in native AOT was attempted, but it was not finished at that time. This line needs to be deleted in release/8.0 branch: runtime/src/installer/pkg/projects/Microsoft.DotNet.ILCompiler/ILCompilerRIDs.props Line 5 in 8966d08
(It should not be deleted in main, because we now do have linux-arm support in 9.0.) @ivanpovazan do you have a sense of how common this situation could be - whether we need to service this? I don't think it affects the non-device scenarios - we had this bug since 7.0 and this is the first time we're hearing about it. |
@am11 sorry for the delayed answer and thanks for pointing it out. Yes, that does seem like the problem. However, I also wanted to bring attention to the fact that if we take the project, open it in Visual Studio for Mac and do publish, the VS will initiate:
Under the hood, it first calls restore target ( My concern is more general and I am trying to figure out how our tools are initiating publish in different scenarios, especially in cases when a certain deployment model (NativeAOT) does not support a certain TFM (net8.0-android) but is specified in a multi-targeted project file, and can we disable it. Specifying runtime identifier makes dotnet restore to take it into account, but is not passed from VS. @MichalStrehovsky, what I described above basically means that MAUI project cannot be published from Visual Studio for Mac with .NET8 and NativeAOT |
The fix has been merged and will become available in the next servicing release. |
Thank you! Do we need to keep this open to track something left? |
My intention was to close it once it is officially available and we do a E2E test. |
Sure, if you don't forget to do that, go for that. My experience is that people forget and the issue will linger open for years. |
Can this be closed now? |
The last servicing release did not include the fix. As I previously mentioned, I will close the issue once the fix is publicly available and was verified that E2E scenario works. |
The fix is included in the latest release of dotnet 8.0.7 (SDK 8.0.303) and it has been verified that the project can be successfully published for iOS from Visual Studio. |
Description
Looking to reduce the .ipa size, this performance improvement notes the setting the PublishAot flag to true should shrink the size.
Our solution has a global.json file which has no pre-release and limiting it to Net SDK 8.203 (8.0.4). Without this flag, the solution builds out release version iOS .ipa as expected; after adding this to the project file in the release section:
true
and reloading the project after the project saves in Visual Studio Mac, an error shows up the package console (or dotnet restore):
_Unable to find a stable package runtime.linux-arm.Microsoft.DotNet.ILCompiler with version (>= 8.0.3)
If a release build done via command line, it gives a similar error.
Given that there is an 8.0.4 version out on the nuget packages for Microsoft.DotNet.ILCompiler, I am unsure why this is occurring. Presently the version is set to 8.0.203, but it also is the same error with 8.0.204.
I also tried to add the nuget for 8.0.4 and it gives a the same error on the project reload.
Reproduction Steps
I've a sample project with the flag set (along with other flags) for a release build showing this behavior for generating a iOS .ipa.
Expected behavior
I would expect this to pull down the 8.0.4 nuget and create a release build .ipa successfully.
Actual behavior
Error on restore (or build if done without restore).
Regression?
If I set the version to 8.0.100 in the global.json, visual studio mac gives this error on the project reload with package restore:
Unable to find a stable package runtime.linux-arm.Microsoft.DotNet.ILCompiler with version (>= 8.0.0)
Restore failed.
Known Workarounds
No workaround; except to not use the PublishAot flag.
Configuration
% dotnet --info
.NET SDK:
Version: 8.0.100
Commit: 57efcf1350
Workload version: 8.0.204-baseline.24170.37
Runtime Environment:
OS Name: Mac OS X
OS Version: 13.6
OS Platform: Darwin
RID: osx-x64
Base Path: /usr/local/share/dotnet/sdk/8.0.100/
.NET workloads installed:
Workload version: 8.0.204-baseline.24170.37
[maui-mobile]
Installation Source: SDK 8.0.100
Manifest Version: 8.0.3/8.0.100
Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.3/WorkloadManifest.json
Install Type: FileBased
Host:
Version: 8.0.4
Architecture: x64
Commit: 2d7eea2
.NET SDKs installed:
5.0.408 [/usr/local/share/dotnet/sdk]
6.0.127 [/usr/local/share/dotnet/sdk]
6.0.419 [/usr/local/share/dotnet/sdk]
6.0.420 [/usr/local/share/dotnet/sdk]
6.0.421 [/usr/local/share/dotnet/sdk]
7.0.116 [/usr/local/share/dotnet/sdk]
7.0.313 [/usr/local/share/dotnet/sdk]
7.0.406 [/usr/local/share/dotnet/sdk]
8.0.100 [/usr/local/share/dotnet/sdk]
8.0.101 [/usr/local/share/dotnet/sdk]
8.0.203 [/usr/local/share/dotnet/sdk]
8.0.204 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.27 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.28 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.29 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.27 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.28 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.29 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
/private/tmp/Projects/PublishAotError/global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Other information
No response
The text was updated successfully, but these errors were encountered: