-
Notifications
You must be signed in to change notification settings - Fork 541
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
Check aar has the correct paths. #9918
Open
dellis1972
wants to merge
11
commits into
main
Choose a base branch
from
dev/dellis1972/createaarissue9879
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0792bd1
to
3b97d32
Compare
3b97d32
to
446cd14
Compare
Draft commit message: Context: https://github.com/dotnet/android/issues/9879
If you create an Android Library project which contains
Android Resources:
% dotnet new androidlib
% mkdir -p Resources/values
% cat > Resources/values/strings.xml <<EOF
<resources>
<string name="lib_name">net9_androidlib</string>
</resources>
EOF
then build the project with `$(MonoAndroidAssetsPrefix)` set to an
absolute path:
dotnet build -p:MonoAndroidAssetsPrefix=`pwd`/Resources
then the resulting `$(MSBuildProjectName).aar` file contains the
absolute path!
% unzip -l bin/Debug/net9.0-android/net9-androidlib.aar
Archive: bin/Debug/net9.0-android/net9-androidlib.aar
Length Date Time Name
--------- ---------- ----- ----
78 04-08-2025 14:32 assets//Users/…/net9-androidlib/Resources/values/strings.xml
71 04-08-2025 14:32 res/values/strings.xml
38 04-08-2025 14:32 .net/__res_name_case_map.txt
This is "nominally fine" on macOS, but if Windows is the source
machine then the entry within the `.aar` contains a `:`, a'la
`assets/D:/a/1/s/Foo.Mobile/Foo.Mobile.Droid/Assets/AboutAssets.txt`,
which can cause a subsequent error XARLP7024 as in dotnet/android#9879:
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: System.IO.IOException: The filename, directory name, or volume label syntax is incorrect. : 'D:\a\1\s\MyCompany.Mobile\MyCompany.Mobile.Droid\obj\Release\net9.0-android\lp\183\jl\assets\D:\a\1\s\MyCompany.Mobile\MyCompany.Mobile.Droid\Assets'.
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: at System.IO.FileSystem.CreateDirectory(String fullPath, Byte[] securityDescriptor)
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: at Microsoft.Android.Build.Tasks.Files.CopyIfStreamChangedOnce(Stream stream, String destination) in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/Files.cs:line 263
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: at Microsoft.Android.Build.Tasks.Files.CopyIfStreamChanged(Stream stream, String destination) in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/Files.cs:line 238
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: at Microsoft.Android.Build.Tasks.Files.ExtractAll(ZipArchive zip, String destination, Action`2 progressCallback, Func`2 modifyCallback, Func`2 deleteCallback, Func`2 skipCallback) in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/Files.cs:line 470
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments, ICollection`1 proguardConfigFiles) in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 398
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: at Xamarin.Android.Tasks.ResolveLibraryProjectImports.RunTask() in /Users/runner/work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/ResolveLibraryProjectImports.cs:line 95
…\Xamarin.Android.EmbeddedResource.targets(39,5): error XARLP7024: at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25
which is *not* fine.
Update the `<CreateAar/>` and `<AndroidComputeResPaths/>` tasks to
verify that the `$(MonoAndroidAssetsPrefix)` MSBuild value is *not*
an absolute path value. If it is, then the "originating" build will
report an error xa1041:
error XA1041: The MSBuild property 'MonoAndroidAssetsPrefix' has an invalid value of '/Absolute/Path'.
The value is expected to be a directory path representing the relative location of your Assets or Resources. |
@dellis1972: also please update |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context #9879
We had a bug report from a user where a zip file ended up with a rooted path as the name for a zip entry.
We had a hard time understanding why this was happening until we really dug into the MSbuild logs
The customer in this case had the following environment variable set on their build process.
AndroidProjectFolder=d:/a/1/s/Foo.Mobile.Droid
.This environment variable effected the code in the Maui
MultiTargeting.targets
[1] which has the following codeBy default this is not a problem. But when the environment variable is set, MSbuild will NOT override the default value.
So in this case we ended up with a
MonoAndroidAssetsPrefix
with a value ofd:/a/1/s/Foo.Mobile.Droid/Assets
.The then caused all sorts of issues when creating .aar files or creating the final apk.
So lets add a new error message to check if the
MonoAndroidAssetsPrefix
or theMonoAndroidResourcePrefix
are rooted paths.[1] https://github.com/dotnet/maui/blob/e41df8ea555f663a552806c075036150300893df/src/MultiTargeting.targets#L77