Skip to content
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

AL1012: 'arm64' is not a valid setting for option 'platform' #28419

Open
rolfbjarne opened this issue Oct 10, 2022 · 14 comments
Open

AL1012: 'arm64' is not a valid setting for option 'platform' #28419

rolfbjarne opened this issue Oct 10, 2022 · 14 comments
Assignees

Comments

@rolfbjarne
Copy link
Member

Describe the bug

When building a project:

  • Using Visual Studio
  • It has localized resources
  • It targets an arm64 platform

This error happens:

AL1012: 'arm64' is not a valid setting for option 'platform'

To Reproduce

https://github.com/ewerspej/dotnet-maui-bug-repro-ios-arm64

This comes from: xamarin/xamarin-macios#16193

This is an iOS project, and it might be easier to create a sample project using this stackoverflow post with the same problem: https://stackoverflow.com/questions/71378075/publish-to-arm64-not-working-when-cultured-resx-file-added

Exceptions (if any)

AL1012: 'arm64' is not a valid setting for option 'platform'

Further technical details

A binlog is available here: https://github.com/ewerspej/dotnet-maui-bug-repro-ios-arm64/blob/main/bug-ios-arm64/bug-ios-arm64_Debug_AnyCPU_net7.0-ios_Build_2022-10-10T09_34_03.0519455%2B02_00.zip

Version: .NET 7.0.100-rc.1.22431.12 (according to xamarin/xamarin-macios#16193).

Analysis

(copied from xamarin/xamarin-macios#16193 (comment))

I think I know what's going on.

When building using either VSMac or the command line (either from Windows or Mac), the MSBuildRuntimeType property is set to Core.

as a result, the default value for GenerateSatelliteAssembliesForCore is true:

<GenerateSatelliteAssembliesForCore Condition=" '$(GenerateSatelliteAssembliesForCore)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">true</GenerateSatelliteAssembliesForCore>

Ref:

<GenerateSatelliteAssembliesForCore Condition=" '$(GenerateSatelliteAssembliesForCore)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">true</GenerateSatelliteAssembliesForCore>

Looks like this logic comes from here:

2506af1

However, when building from inside Visual Studio (for Windows), the MSBuildRuntimeType property is set to Full, and thus GenerateSatelliteAssembliesForCore is not set to true, and we end up executing al.exe to generate satellite assemblies, which is wrong.

It seems to me that the problem is the logic to determine whether al.exe should be used or not, it shouldn't depend on where MSBuild is executing, but instead what kind of project is being built.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels Oct 10, 2022
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Oct 10, 2022
…sembliesForCore. Fixes xamarin#16193.

Hardcode 'true' as the default value for GenerateSatelliteAssembliesForCore,
because .NET gets it wrong when building from inside VS (Windows).

When building using either VSMac or the command line (either from Windows or
Mac), the `MSBuildRuntimeType` property is set to `Core`, and as a result, the
default value for `GenerateSatelliteAssembliesForCore` is `true`:

```xml
<GenerateSatelliteAssembliesForCore Condition=" '$(GenerateSatelliteAssembliesForCore)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">true</GenerateSatelliteAssembliesForCore>
```

See: https://github.com/dotnet/sdk/blob/00100960bf06cb595daba647673cd0329be896f4/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L41

This is the correct behavior.

However, when building from inside Visual Studio (for Windows), the
`MSBuildRuntimeType` property is set to `Full`, and thus
`GenerateSatelliteAssembliesForCore` is not set to `true`, and we end up
executing al.exe to generate satellite assemblies, which is wrong (al.exe
complains that 'arm64' is an invalid platform).

Fix this by always defaulting `GenerateSatelliteAssembliesForCore` to `true`,
independent on where we're executing.

Ref: dotnet/sdk#28419.

Fixes xamarin#16193.
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Oct 10, 2022
…sembliesForCore. Fixes xamarin#16193.

Hardcode 'true' as the default value for GenerateSatelliteAssembliesForCore,
because .NET gets it wrong when building from inside VS (Windows).

When building using either VSMac or the command line (either from Windows or
Mac), the `MSBuildRuntimeType` property is set to `Core`, and as a result, the
default value for `GenerateSatelliteAssembliesForCore` is `true`:

```xml
<GenerateSatelliteAssembliesForCore Condition=" '$(GenerateSatelliteAssembliesForCore)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">true</GenerateSatelliteAssembliesForCore>
```

See: https://github.com/dotnet/sdk/blob/00100960bf06cb595daba647673cd0329be896f4/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L41

This is the correct behavior.

However, when building from inside Visual Studio (for Windows), the
`MSBuildRuntimeType` property is set to `Full`, and thus
`GenerateSatelliteAssembliesForCore` is not set to `true`, and we end up
executing al.exe to generate satellite assemblies, which is wrong (al.exe
complains that 'arm64' is an invalid platform).

Fix this by always defaulting `GenerateSatelliteAssembliesForCore` to `true`,
independent on where we're executing.

Ref: dotnet/sdk#28419.

Fixes xamarin#16193.
rolfbjarne added a commit to xamarin/xamarin-macios that referenced this issue Oct 10, 2022
…sembliesForCore. Fixes #16193. (#16306)

Hardcode 'true' as the default value for GenerateSatelliteAssembliesForCore,
because .NET gets it wrong when building from inside VS (Windows).

When building using either VSMac or the command line (either from Windows or
Mac), the `MSBuildRuntimeType` property is set to `Core`, and as a result, the
default value for `GenerateSatelliteAssembliesForCore` is `true`:

```xml
<GenerateSatelliteAssembliesForCore Condition=" '$(GenerateSatelliteAssembliesForCore)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">true</GenerateSatelliteAssembliesForCore>
```

See: https://github.com/dotnet/sdk/blob/00100960bf06cb595daba647673cd0329be896f4/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L41

This is the correct behavior.

However, when building from inside Visual Studio (for Windows), the
`MSBuildRuntimeType` property is set to `Full`, and thus
`GenerateSatelliteAssembliesForCore` is not set to `true`, and we end up
executing al.exe to generate satellite assemblies, which is wrong (al.exe
complains that 'arm64' is an invalid platform).

Fix this by always defaulting `GenerateSatelliteAssembliesForCore` to `true`,
independent on where we're executing.

Ref: dotnet/sdk#28419.

Fixes #16193.
@marcpopMSFT
Copy link
Member

@dsplaisted let's chat when you're back to understand more about this.

@IgorKravchenko10
Copy link

IgorKravchenko10 commented Oct 31, 2022

I am trying to build my project and get this error too in Visual Studio 17.4.0 Preview 5.0
Here is the sample. I just added Translator.resx, Translator.uk.resx, Translator.ru.resx to project and now unable to compile in release mode.
MauiApp1.zip

All works after adding
<GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
to project file.

@dsplaisted dsplaisted added needs team triage Requires a full team discussion and removed untriaged Request triage from a team member labels Nov 9, 2022
@dsplaisted dsplaisted removed their assignment Nov 9, 2022
@marcpopMSFT
Copy link
Member

@rainersigwald Do you know who owns Al.exe and if it supports arm64? Is setting that property the appropriate workaround here?

@dsplaisted
Copy link
Member

We only set GenerateSatelliteAssembliesForCore when MSBuildRuntimeType is Core:

<GenerateSatelliteAssembliesForCore Condition=" '$(GenerateSatelliteAssembliesForCore)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">true</GenerateSatelliteAssembliesForCore>

We should probably expand the condition to use it went not targeting full .NET Framework, or when targeting ARM, or something.

@benvillalobos
Copy link
Member

We should probably expand the condition to use it went not targeting full .NET Framework, or when targeting ARM, or something.

If the tool doesn't support ARM, the condition to stop it from running should be based on arm until it gets arm64 support imo

@Forgind
Copy link
Member

Forgind commented Nov 16, 2022

Don't we own AL.exe? We have an AL task, and looking at that, it was last touched by BenVillalobos in adding platform support (then me in fixing a nre), not including style things. It seems to have explicit support for x86 and x64, but then falls back to the "CurrenProcessArchitecture", so we might just have to add ARM as an option.

@benvillalobos
Copy link
Member

@Forgind We don't, our AL task is a tooltask that shells out to Al.exe. The error code AL1012 shows the tool ran but was passed a flag it didn't support.

It seems to have explicit support for x86 and x64, but then falls back to the "CurrenProcessArchitecture", so we might just have to add ARM as an option.

My change added a check for which version of Al.exe to call (32 bit or 64 bit), not support for a new platform within the tool. Adding an arm64 check in our task wouldn't resolve this particular issue.

@dsplaisted
Copy link
Member

If GenerateSatelliteAssembliesForCore is set, then we use the Csc task instead of AL.exe to generate the satellite assemblies.

Does AL.exe have any capabilities that the Roslyn compilers wouldn't? Is there any reason to keep using AL.exe over Roslyn for projects that aren't targeting .NET Framework? (In any case, we already use Roslyn for dotnet build, just not full Framework msbuild.

@AArnott
Copy link
Contributor

AArnott commented Nov 22, 2022

This is blocking our upgrade to using the .NET 7 SDK. It looks like a lot of talk about has to do with this specific case, but it's very general. The only thing you need to repro is a vanilla C# class library project that has non-default culture resources that includes an arm64 target.

Repro

  1. Unzip this: ClassLibrary2.zip
  2. Build the arm64 platform.

I believe the regression came because of adding arm64 targeting support to the SDK:
image
But the GenerateSatelliteAssemblies target consumes $(PlatformTarget) property and passes it the al.exe, which doesn't consider arm64 to be a valid platform.

@marcpopMSFT
Copy link
Member

@AArnott can you not set GenerateSatelliteAssembliesForCore to work around this? Per Daniel above, our fix for this is going to be setting that property when targeting core and I want to confirm that that's enough to unblock you.

@marcpopMSFT marcpopMSFT removed the needs team triage Requires a full team discussion label Nov 23, 2022
@marcpopMSFT
Copy link
Member

Not sure if setting this only targeting core will be enough since 481 supports arm64. Chat with Daniel

@AArnott
Copy link
Contributor

AArnott commented Nov 23, 2022

Exactly right: my project isn't actually targeting .NET. It's targeting .NET Framework.

@dsplaisted
Copy link
Member

Even if you're targeting .NET Framework, I believe that GenerateSatelliteAssembliesForCore will work for you.

@AArnott
Copy link
Contributor

AArnott commented Nov 28, 2022

Thanks. I already devised a different workaround though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants