-
Notifications
You must be signed in to change notification settings - Fork 562
F# Android projects don't build when language is changed in XS fixes … #175
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
Conversation
Please improve the commit message. What is What does "when language is changed in XS" mean? Programming language? Human translation language? Something else? 6 months from now, how are we going to understand the intent behind this change? All of that should go into the commit message. |
4c32e3d
to
4a872e0
Compare
Setting the UI language in XS sets the msbuild variable `LANGUAGE = en` (or whatever language you choose). The Android F# targets check for the existence of this variable to determine if Microsoft.FSharp.targets has been loaded. Microsoft.FSharp.targets sets `<Language>F#</Language>` so it is better to check for the presence of F# being set rather than checking to see if it's not empty. Fixes #43525
4a872e0
to
f4b1701
Compare
Yeah, sorry. It was late. Fixed comment. |
Thank you for the updated commit message. It now raises more questions. :-)
Why is this necessary? To prevent multiple inclusion of the If the IDE is using Here's a concern/scenario: MSBuild properties specified on the command line cannot be overridden in Consider this simple MSBuild project, which
The file is named, for example purposes, as
Build it, and it's fine:
Override the Language property, and it's not so fine:
We now have warnings, because the condition on the second import wasn't what we thought it was, because properties specified on the command-line are immutable. To bring us full circle, how is XS specifying the I have no idea, but to me this means that you cannot rely on the |
Yes. I agree that this is a kludge but I don't see an easy solution. The problem is that MSBuild takes input from all environment variables.
The build breaks if the Microsoft.FSharp.targets file is imported twice. Microsoft.FSharp.targets imports the following properties
I'm no expert in MSBuild so open to other ideas but it seems that we need to detect one of these to know if it's already loaded. |
Yes, but environment variables aren't the same as command-line arguments!
If XS is exporting the LANGUAGE environment variable, that's fine, afaict. If it's exporting an immutable MSBuild property, that'll break stuff. Which is XS doing? If XS is exporting an environment variable, are we sure we understand this bug correctly, and that it's not something else? If XS is exporting an immutable MSBuild property, why is XS exporting an immutable MSBuild property? Can that be changed? |
//cc @mhutch advice please |
Here's another plausible fix. This is in
Mono.framework could add a file here which imports a new, unambiguous, MSBuild property, such as Alas, that would be Mono-specific. |
XS is exporting an environment variable but MSBuild converts all env vars into MSBuild vars. See here for a diagnostic build log (containing this fix) |
Maybe I can explain it more clearly.
So - I see 2 possible solutions: a. Instead of checking whether b. Check some other property that is set by the F# targets. I didn't see a good candidate though. [edited for accuracy] |
This is incorrect, as demonstrated above. Command-line provided parameter values are immutable, and cannot be overridden, by anything.
I didn't see a good candidate either. :-( |
Merged with a more "elaborate" commit message. |
… exported (#175) Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=43525 **gettext**(3) and Unix in general use the `$LANGUAGE` environment variable to determine which *human* language translations should be used when showing user-visible strings. MSBuild exports all environment variables as MSBuild properties, and MSBuild is case-insensitive, so the `$LANGUAGE` environment variable is accessible as the `$(Language)` MSBuild property. `Microsoft.FSharp.targets` sets the `$(Language)` MSBuild property, and `Xamarin.Android.FSharp.targets` uses the value of `$(Language)` to determine if `Microsoft.FSharp.targets` has already been imported, and only import `Microsoft.FSharp.targets` if it hasn't been, using: <Import Condition=" '$(Language)' == '' And Exists ('path\to\Microsoft.FSharp.targets')" Project="path\to\Microsoft.FSharp.targets" /> Therein lies the problem: if (when) the `$LANGUAGE` environment variable is set, the above `Condition` check doesn't behave as expected, causing `Microsoft.FSharp.targets` to *not* be imported when it *should* be imported. Fix `//Import/@Condition` so that, instead of comparing against the empty string -- which can be misleading -- it instead compares against the string `F#`, which is *not* a valid `$LANGUAGE` value: <Import Condition=" '$(Language)' != 'F#' And Exists ('path\to\Microsoft.FSharp.targets')" Project="path\to\Microsoft.FSharp.targets" /> This allows `Microsoft.FSharp.targets` to be properly imported, no matter what the value of the `$LANGUAGE` environment variable.
Thanks for the correction. Making vars from the command-line immutable also seems like a weird design decision :) Property from env vars are definitely mutable though. |
Great. Thanks! |
Changes: TODO Java.Interop Changes: dotnet/android-tools@9c641b3...7cfe683 * dotnet/android-tools@7cfe683: [ci] Use Microsoft.SourceLink.GitHub (dotnet#192) * dotnet/android-tools@01a0dde: [Localization] Import translated resx files (dotnet#189) * dotnet/android-tools@cc715d9: [Xamarin.Android.Tools.AndroidSdk] Permit NDK r25 (dotnet#190) * dotnet/android-tools@3c55e9a: Avoid `Environment.SpecialFolder.ApplicationData` (dotnet#188) * dotnet/android-tools@0d55472: LEGO: Merge pull request 187 * dotnet/android-tools@6946512: Juno: check in to juno/hb_befb220e-87ce-47e9-a9e6-10ea592b2337_20220729154833425. (dotnet#186) * dotnet/android-tools@6e3433a: Juno: check in to juno/hb_befb220e-87ce-47e9-a9e6-10ea592b2337_20220729025332507. (dotnet#185) * dotnet/android-tools@73c4388: [Xamarin.Android.Tools.AndroidSdk] Update SDK component for API-33 (dotnet#184) * dotnet/android-tools@da3653e: [Xamarin.Android.Tools.AndroidSdk] Add API-33 to KnownVersions * dotnet/android-tools@327d433: [ci] Run OneLocBuild on a schedule (dotnet#180) * dotnet/android-tools@8ab60e4: [ci] Use latest macOS and Windows images (dotnet#181) * dotnet/android-tools@4dd3292: LEGO: Merge pull request 182 * dotnet/android-tools@56b61f1: [Localization] Add OneLocBuild job (dotnet#175) * dotnet/android-tools@14076a6: [Xamarin.Android.Tools.AndroidSdk] Add API-32 to KnownVersions
…7309) Changes: mono/mono.posix@e1269a5...d8994ca * mono/mono.posix@d8994ca: Remove Windows support completely for now Fixes an issue in which Mono.Unix would try to resolve `libc` P/Invokes by looking for the `msvcrt` library on Unix machines. * mono/mono.posix@74d504f: Fix yaml template path * mono/mono.posix@127cf9e: [build] Don't rebuild managed code on packaging time on Windows Changes: dotnet/android-libzipsharp@2.0.4...2.0.7 * dotnet/android-libzipsharp@98e9173: Bump version to 2.0.7 * dotnet/android-libzipsharp@6e1e1b3: Localized file check-in by OneLocBuild Task: Build definition ID 11678: Build ID 6581869 (#119) * dotnet/android-libzipsharp@1c05430: LEGO: Merge pull request 118 * dotnet/android-libzipsharp@06d44d8: Localized file check-in by OneLocBuild Task: Build definition ID 11678: Build ID 6570668 (#117) * dotnet/android-libzipsharp@37f3894: LEGO: Merge pull request 116 * dotnet/android-libzipsharp@6c0edc5: Update libzip and zlib submodules (#115) * dotnet/android-libzipsharp@acd9a54: [Localization] Switch from xlf to resx files (#112) * dotnet/android-libzipsharp@3cece80: LEGO: Merge pull request 114 * dotnet/android-libzipsharp@fe336b4: LEGO: Merge pull request 113 * dotnet/android-libzipsharp@9aee99a: [Localization] Add OneLocBuild job (#111) * dotnet/android-libzipsharp@bdfa9f8: Bump Mono.Unix to 7.1.0-final.1.21458.1 (#110) Changes: xamarin/monodroid@210073e...100ccf9 * xamarin/monodroid@100ccf969: Bump to xamarin/androidtools@81486ab, xamarin/android-sdk-installer@8cac7ea (#1264) Changes: dotnet/android-tools@9c641b3...29f11f2 * dotnet/android-tools@29f11f2 Bump to mono/mono.posix@d8994ca, dotnet/android-libzipsharp@98e9173 (#193) * dotnet/android-tools@7cfe683 [ci] Use Microsoft.SourceLink.GitHub (#192) * dotnet/android-tools@01a0dde [Localization] Import translated resx files (#189) * dotnet/android-tools@cc715d9 [Xamarin.Android.Tools.AndroidSdk] Permit NDK r25 (#190) * dotnet/android-tools@3c55e9a Avoid `Environment.SpecialFolder.ApplicationData` (#188) * dotnet/android-tools@0d55472 LEGO: Merge pull request 187 * dotnet/android-tools@6946512 Juno: check in to juno/hb_befb220e-87ce-47e9-a9e6-10ea592b2337_20220729154833425. (#186) * dotnet/android-tools@6e3433a Juno: check in to juno/hb_befb220e-87ce-47e9-a9e6-10ea592b2337_20220729025332507. (#185) * dotnet/android-tools@73c4388 [Xamarin.Android.Tools.AndroidSdk] Update SDK component for API-33 (#184) * dotnet/android-tools@da3653e [Xamarin.Android.Tools.AndroidSdk] Add API-33 to KnownVersions * dotnet/android-tools@327d433 [ci] Run OneLocBuild on a schedule (#180) * dotnet/android-tools@8ab60e4 [ci] Use latest macOS and Windows images (#181) * dotnet/android-tools@4dd3292 LEGO: Merge pull request 182 * dotnet/android-tools@56b61f1 [Localization] Add OneLocBuild job (#175) * dotnet/android-tools@14076a6 [Xamarin.Android.Tools.AndroidSdk] Add API-32 to KnownVersions
F# projects don't build when lang is changed in XS
Setting the UI language in XS sets the msbuild variable
LANGUAGE = en
(or whatever language you choose).
The Android F# targets check for the existence of this variable to
determine if Microsoft.FSharp.targets has been loaded.
Microsoft.FSharp.targets sets
<Language>F#</Language>
so it is betterto check for the presence of F# being set rather than checking to see
if it's not empty.
Fixes #43525