From 92d1da8761596728c73f48bcdb924d37719d3c89 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Tue, 18 Feb 2025 19:44:39 +0000 Subject: [PATCH 01/15] Add Asset Error APT2266 --- Documentation/docs-mobile/messages/apt2266.md | 26 +++++++++++++++++++ Documentation/docs-mobile/messages/index.md | 1 + .../Properties/Resources.Designer.cs | 9 +++++++ .../Properties/Resources.resx | 4 +++ .../Tasks/Aapt2.cs | 22 ++++++++++++++++ .../Tasks/Aapt2Link.cs | 16 +++++++++++- .../Tasks/Aapt2LinkAssetPack.cs | 7 ++++- .../BuildAssetsTest.cs | 20 ++++++++++++++ .../Xamarin.Android.Build.Tests/BuildTest.cs | 8 +++++- 9 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 Documentation/docs-mobile/messages/apt2266.md diff --git a/Documentation/docs-mobile/messages/apt2266.md b/Documentation/docs-mobile/messages/apt2266.md new file mode 100644 index 00000000000..df1e99b0a87 --- /dev/null +++ b/Documentation/docs-mobile/messages/apt2266.md @@ -0,0 +1,26 @@ +--- +title: .NET for Android error APT2266 +description: APT2266 error code +ms.date: 04/11/2024 +--- +# .NET for Android error APT2266 + +## Example messages + +``` +error APT2266: Asset directories cannot use non ascii characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. +``` + +## Issue + +The Full Path to the directory you are trying to use as an Asset Directory +contains non-ASCII characters. The `aapt2` tool has a known bug where it cannot traverse directories with non-ASCII characters [1]. +This is commonly caused by users having non-ASCII characters in their usernames, or in the project folders. + +[1] https://issuetracker.google.com/issues/188679588 + +## Solution + +Rename the folder which contains non-ASCII characters to something which only has ASCII characters. If it is your username which has the non-ASCII +characters, the only solution is to move the project somewhere outside of +your user path. Most common solutions is to have a working or sandbox directory off the root of your drive rather than creating projects in `c:\Users\xxx`. \ No newline at end of file diff --git a/Documentation/docs-mobile/messages/index.md b/Documentation/docs-mobile/messages/index.md index 73993e4b3e2..09b162b94eb 100644 --- a/Documentation/docs-mobile/messages/index.md +++ b/Documentation/docs-mobile/messages/index.md @@ -34,6 +34,7 @@ ms.date: 04/11/2024 + [APT2000](apt2000.md): Generic `aapt2` error/warning. + [APT2264](apt2264.md): The system cannot find the file specified. (2). + [APT2265](apt2265.md): The system cannot find the file specified. (2). ++ [APT2266](apt2266.md): Asset directories cannot use non ascii characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. ## JAVAxxxx: Java Tool diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs index 636e491f4a9..f5adb708858 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs @@ -134,6 +134,15 @@ public static string APT2265 { } } + /// + /// Looks up a localized string similar to This could be caused by the project having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2265 for details.. + /// + public static string APT2266 { + get { + return ResourceManager.GetString("APT2266", resourceCulture); + } + } + /// /// Looks up a localized string similar to Directory '{0}' is from '{1}'.. /// diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index d58057272af..0ab9c7efe63 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -564,6 +564,10 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla This could be caused by the project having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2265 for details. The following are literal names and should not be translated: + + Asset directories cannot use non ascii characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. + The following are literal names and should not be translated: + Could not AOT the assembly: {0} The abbreviation "AOT" should not be translated. diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs index 97d631aa698..d3c23af9e71 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs @@ -52,6 +52,28 @@ public abstract class Aapt2 : AsyncTask { public static bool IsInvalidFilename (string path) => Path.GetFileName (path).StartsWith (".", StringComparison.Ordinal); + /// + /// Returns if is an ASCII + /// character ([ U+0000..U+007F ]). + /// + /// + /// Per http://www.unicode.org/glossary/#ASCII, ASCII is only U+0000..U+007F. + /// We cannot use Char.IsAscii cos we are .netstandard2.0 + /// Source https://github.com/dotnet/runtime/blob/1d1bf92fcf43aa6981804dc53c5174445069c9e4/src/libraries/System.Private.CoreLib/src/System/Char.cs#L91 + /// + public static bool IsAscii(char c) => (uint)c <= '\x007f'; + /// + /// Returns true if the path has non-ASCII characters. + /// + /// The path to be checked + /// + public static bool IsInvalidDirectoryName (string path) { + foreach (var c in path) + if (!IsAscii(c)) + return true; + return false; + } + protected string ResourceDirectoryFullPath (string resourceDirectory) { return (Path.IsPathRooted (resourceDirectory) ? resourceDirectory : Path.Combine (WorkingDirectory, resourceDirectory)).TrimEnd ('\\'); diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs index 4dd27c19321..046a9bdaa2b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs @@ -272,11 +272,16 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s } } + var hasAssetsErrors = false; // When adding Assets the first item found takes precedence. - // So we need to add the applicaiton Assets first. + // So we need to add the application Assets first. if (!string.IsNullOrEmpty (AssetsDirectory)) { var assetDir = GetFullPath (AssetsDirectory.TrimEnd ('\\')); if (Directory.Exists (assetDir)) { + if (IsInvalidDirectoryName (assetDir)) { + hasAssetsErrors = true; + LogCodedError ("APT2266", Properties.Resources.APT2266, assetDir); + } cmd.Add ("-A"); cmd.Add (assetDir); } else { @@ -289,6 +294,11 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s var assetDir = GetFullPath (AdditionalAndroidAssetPaths [i].ItemSpec.TrimEnd ('\\')); if (!string.IsNullOrWhiteSpace (assetDir)) { if (Directory.Exists (assetDir)) { + if (IsInvalidDirectoryName (assetDir)) { + hasAssetsErrors = true; + LogCodedError ("APT2266", Properties.Resources.APT2266, assetDir); + continue; + } cmd.Add ("-A"); cmd.Add (GetFullPath (assetDir)); } else { @@ -298,6 +308,10 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s } } + if (hasAssetsErrors) { + return Array.Empty (); + } + if (!string.IsNullOrEmpty (ProguardRuleOutput)) { cmd.Add ("--proguard"); cmd.Add (GetFullPath (GetManifestRulesFile (manifestDir))); diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs index 7c9a1f16a5a..eb7dacc368e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs @@ -63,8 +63,13 @@ protected string[] GenerateCommandLineCommands (ITaskItem manifest, ITaskItem ou cmd.Add ("--custom-package"); cmd.Add (PackageName); foreach (var assetDirectory in AssetDirectories) { + var fullPath = GetFullPath (assetDirectory.ItemSpec); + if (IsInvalidDirectoryName (fullPath)) { + LogCodedError ("APT2266", Properties.Resources.APT2266, fullPath); + continue; + } cmd.Add ("-A"); - cmd.Add (GetFullPath (assetDirectory.ItemSpec)); + cmd.Add (fullPath); } cmd.Add ($"-o"); cmd.Add (GetFullPath (output.ItemSpec)); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs index 734848651bd..a161ba247b9 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs @@ -133,6 +133,26 @@ public void CheckAssetsAreIncludedInAPK () } } + [Test] + public void InvalidAssetDirectoryWithNonASCIIChars () + { + var proj = new XamarinAndroidApplicationProject () { + ProjectName = "App1", + IsRelease = true, + OtherBuildItems = { + new AndroidItem.AndroidAsset ("Assets\\asset1.txt") { + TextContent = () => "Asset1", + Encoding = Encoding.ASCII, + }, + }, + }; + using (var b = CreateApkBuilder (Path.Combine ("temp", "InvalidAssetDirectoryWithNonASCIIChars_Ümläüt", proj.ProjectName))) { + b.ThrowOnBuildFailure = false; + Assert.IsFalse (b.Build (proj), "{0} should not have built successfully.", proj.ProjectName); + Assert.IsTrue (b.LastBuildOutput.ContainsText ("APT2266"), "Expected APT2266 error not found."); + } + } + [Test] public void FullPath () { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index 20abc9bfe34..d6626198aaf 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -659,7 +659,13 @@ public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enable IsRelease = true, AotAssemblies = true, LinkTool = linkTool, - References = { new BuildItem ("ProjectReference", $"..\\{folderName}Library1\\Library1.csproj") } + References = { new BuildItem ("ProjectReference", $"..\\{folderName}Library1\\Library1.csproj") }, + OtherBuildItems = { + new AndroidItem.AndroidAsset ("Assets\\..\asset1.txt") { + TextContent = () => "Asset1", + Encoding = Encoding.ASCII, + }, + }, }; proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "Hello (World).jar") { BinaryContent = () => Convert.FromBase64String (@" UEsDBBQACAgIAMl8lUsAAAAAAAAAAAAAAAAJAAQATUVUQS1JTkYv/soAAAMAUEsHCAAAAAACAAAAA From 4f41b64b97d14ca64ec1032979b467b52dfa8229 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 19 Feb 2025 09:27:03 +0000 Subject: [PATCH 02/15] Formatting --- src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs index d3c23af9e71..f5a51835cbd 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs @@ -53,15 +53,15 @@ public static bool IsInvalidFilename (string path) => Path.GetFileName (path).StartsWith (".", StringComparison.Ordinal); /// - /// Returns if is an ASCII - /// character ([ U+0000..U+007F ]). - /// - /// - /// Per http://www.unicode.org/glossary/#ASCII, ASCII is only U+0000..U+007F. + /// Returns if is an ASCII + /// character ([ U+0000..U+007F ]). + /// + /// + /// Per http://www.unicode.org/glossary/#ASCII, ASCII is only U+0000..U+007F. /// We cannot use Char.IsAscii cos we are .netstandard2.0 /// Source https://github.com/dotnet/runtime/blob/1d1bf92fcf43aa6981804dc53c5174445069c9e4/src/libraries/System.Private.CoreLib/src/System/Char.cs#L91 - /// - public static bool IsAscii(char c) => (uint)c <= '\x007f'; + /// + public static bool IsAscii(char c) => (uint)c <= '\x007f'; /// /// Returns true if the path has non-ASCII characters. /// From 3b83b7f5a708c475b2239796102bb717deee6ab0 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 19 Feb 2025 10:59:48 +0000 Subject: [PATCH 03/15] Fix a test maybe --- .../Tests/Xamarin.Android.Build.Tests/BuildTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index d6626198aaf..abb3eeb106a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -661,7 +661,7 @@ public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enable LinkTool = linkTool, References = { new BuildItem ("ProjectReference", $"..\\{folderName}Library1\\Library1.csproj") }, OtherBuildItems = { - new AndroidItem.AndroidAsset ("Assets\\..\asset1.txt") { + new AndroidItem.AndroidAsset ("Assets\\..\\asset1.txt") { TextContent = () => "Asset1", Encoding = Encoding.ASCII, }, From 122aaea12cdc91b98c3306b38f56e245d9826807 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 19 Feb 2025 14:20:26 +0000 Subject: [PATCH 04/15] Trt this --- .../Tests/Xamarin.Android.Build.Tests/BuildTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index abb3eeb106a..069c3a943bc 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -661,7 +661,7 @@ public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enable LinkTool = linkTool, References = { new BuildItem ("ProjectReference", $"..\\{folderName}Library1\\Library1.csproj") }, OtherBuildItems = { - new AndroidItem.AndroidAsset ("Assets\\..\\asset1.txt") { + new AndroidItem.AndroidAsset ("Assets\\asset1.txt") { TextContent = () => "Asset1", Encoding = Encoding.ASCII, }, From 4c95f1f21ee4b02ea3136ba5dfed6df0c7fa86bb Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 19 Feb 2025 16:06:12 +0000 Subject: [PATCH 05/15] Back out this change as we cannot fix it --- .../Tests/Xamarin.Android.Build.Tests/BuildTest.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index 069c3a943bc..5fa64aa2305 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -660,12 +660,6 @@ public void BuildApplicationWithSpacesInPath ([Values (true, false)] bool enable AotAssemblies = true, LinkTool = linkTool, References = { new BuildItem ("ProjectReference", $"..\\{folderName}Library1\\Library1.csproj") }, - OtherBuildItems = { - new AndroidItem.AndroidAsset ("Assets\\asset1.txt") { - TextContent = () => "Asset1", - Encoding = Encoding.ASCII, - }, - }, }; proj.OtherBuildItems.Add (new BuildItem ("AndroidJavaLibrary", "Hello (World).jar") { BinaryContent = () => Convert.FromBase64String (@" UEsDBBQACAgIAMl8lUsAAAAAAAAAAAAAAAAJAAQATUVUQS1JTkYv/soAAAMAUEsHCAAAAAACAAAAA From 6b3e0dc737c2000265d13f7e0726a21ebaac4d06 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 20 Feb 2025 07:59:58 +0000 Subject: [PATCH 06/15] Fix casing --- src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index 0ab9c7efe63..32b72759b88 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -565,8 +565,9 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla The following are literal names and should not be translated: - Asset directories cannot use non ascii characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. - The following are literal names and should not be translated: + Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. + The following are literal names and should not be translated: +ASCII Could not AOT the assembly: {0} From 61776850fba01b2d60ff82f0bcd4f9149e2077ce Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 20 Feb 2025 17:25:15 +0000 Subject: [PATCH 07/15] Fix text --- Documentation/docs-mobile/messages/apt2266.md | 2 +- Documentation/docs-mobile/messages/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/docs-mobile/messages/apt2266.md b/Documentation/docs-mobile/messages/apt2266.md index df1e99b0a87..b1d9c00a021 100644 --- a/Documentation/docs-mobile/messages/apt2266.md +++ b/Documentation/docs-mobile/messages/apt2266.md @@ -8,7 +8,7 @@ ms.date: 04/11/2024 ## Example messages ``` -error APT2266: Asset directories cannot use non ascii characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. +error APT2266: Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. ``` ## Issue diff --git a/Documentation/docs-mobile/messages/index.md b/Documentation/docs-mobile/messages/index.md index 09b162b94eb..bb009b3131d 100644 --- a/Documentation/docs-mobile/messages/index.md +++ b/Documentation/docs-mobile/messages/index.md @@ -34,7 +34,7 @@ ms.date: 04/11/2024 + [APT2000](apt2000.md): Generic `aapt2` error/warning. + [APT2264](apt2264.md): The system cannot find the file specified. (2). + [APT2265](apt2265.md): The system cannot find the file specified. (2). -+ [APT2266](apt2266.md): Asset directories cannot use non ascii characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. ++ [APT2266](apt2266.md): Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. ## JAVAxxxx: Java Tool From c3897868627e57157b2e2b6ee3a791ec519d511d Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 09:00:52 +0000 Subject: [PATCH 08/15] Changed to Aapt2267 as a 2266 exists --- .../docs-mobile/messages/{apt2266.md => apt2267.md} | 12 ++++++------ Documentation/docs-mobile/messages/index.md | 2 +- src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs | 4 ++-- .../Tasks/Aapt2LinkAssetPack.cs | 2 +- .../Xamarin.Android.Build.Tests/BuildAssetsTest.cs | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) rename Documentation/docs-mobile/messages/{apt2266.md => apt2267.md} (79%) diff --git a/Documentation/docs-mobile/messages/apt2266.md b/Documentation/docs-mobile/messages/apt2267.md similarity index 79% rename from Documentation/docs-mobile/messages/apt2266.md rename to Documentation/docs-mobile/messages/apt2267.md index b1d9c00a021..4d74d2a5bf8 100644 --- a/Documentation/docs-mobile/messages/apt2266.md +++ b/Documentation/docs-mobile/messages/apt2267.md @@ -1,14 +1,14 @@ --- -title: .NET for Android error APT2266 -description: APT2266 error code +title: .NET for Android error APT2267 +description: APT2267 error code ms.date: 04/11/2024 --- -# .NET for Android error APT2266 +# .NET for Android error APT2267 ## Example messages -``` -error APT2266: Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. +```cli +error APT2267: Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. ``` ## Issue @@ -23,4 +23,4 @@ This is commonly caused by users having non-ASCII characters in their usernames, Rename the folder which contains non-ASCII characters to something which only has ASCII characters. If it is your username which has the non-ASCII characters, the only solution is to move the project somewhere outside of -your user path. Most common solutions is to have a working or sandbox directory off the root of your drive rather than creating projects in `c:\Users\xxx`. \ No newline at end of file +your user path. Most common solutions is to have a working or sandbox directory off the root of your drive rather than creating projects in `c:\Users\xxx`. diff --git a/Documentation/docs-mobile/messages/index.md b/Documentation/docs-mobile/messages/index.md index bb009b3131d..6ebe800ebb2 100644 --- a/Documentation/docs-mobile/messages/index.md +++ b/Documentation/docs-mobile/messages/index.md @@ -34,7 +34,7 @@ ms.date: 04/11/2024 + [APT2000](apt2000.md): Generic `aapt2` error/warning. + [APT2264](apt2264.md): The system cannot find the file specified. (2). + [APT2265](apt2265.md): The system cannot find the file specified. (2). -+ [APT2266](apt2266.md): Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. ++ [APT2266](apt2267.md): Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. ## JAVAxxxx: Java Tool diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs index 046a9bdaa2b..5b31360937b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs @@ -280,7 +280,7 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s if (Directory.Exists (assetDir)) { if (IsInvalidDirectoryName (assetDir)) { hasAssetsErrors = true; - LogCodedError ("APT2266", Properties.Resources.APT2266, assetDir); + LogCodedError ("APT2267", Properties.Resources.APT2267, assetDir); } cmd.Add ("-A"); cmd.Add (assetDir); @@ -296,7 +296,7 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s if (Directory.Exists (assetDir)) { if (IsInvalidDirectoryName (assetDir)) { hasAssetsErrors = true; - LogCodedError ("APT2266", Properties.Resources.APT2266, assetDir); + LogCodedError ("APT2267", Properties.Resources.APT2267, assetDir); continue; } cmd.Add ("-A"); diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs index eb7dacc368e..ec7c10ebabc 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs @@ -65,7 +65,7 @@ protected string[] GenerateCommandLineCommands (ITaskItem manifest, ITaskItem ou foreach (var assetDirectory in AssetDirectories) { var fullPath = GetFullPath (assetDirectory.ItemSpec); if (IsInvalidDirectoryName (fullPath)) { - LogCodedError ("APT2266", Properties.Resources.APT2266, fullPath); + LogCodedError ("APT2267", Properties.Resources.APT2267, fullPath); continue; } cmd.Add ("-A"); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs index a161ba247b9..57da5685942 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs @@ -149,7 +149,7 @@ public void InvalidAssetDirectoryWithNonASCIIChars () using (var b = CreateApkBuilder (Path.Combine ("temp", "InvalidAssetDirectoryWithNonASCIIChars_Ümläüt", proj.ProjectName))) { b.ThrowOnBuildFailure = false; Assert.IsFalse (b.Build (proj), "{0} should not have built successfully.", proj.ProjectName); - Assert.IsTrue (b.LastBuildOutput.ContainsText ("APT2266"), "Expected APT2266 error not found."); + Assert.IsTrue (b.LastBuildOutput.ContainsText ("APT2267"), "Expected APT2267 error not found."); } } From fd94d54a9ea34829bf5fe6738acc5a5c29519cee Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 09:03:13 +0000 Subject: [PATCH 09/15] grrrrrr --- Documentation/docs-mobile/messages/index.md | 2 +- .../Properties/Resources.Designer.cs | 6 +++--- src/Xamarin.Android.Build.Tasks/Properties/Resources.resx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/docs-mobile/messages/index.md b/Documentation/docs-mobile/messages/index.md index 6ebe800ebb2..e7c6ecdb2cf 100644 --- a/Documentation/docs-mobile/messages/index.md +++ b/Documentation/docs-mobile/messages/index.md @@ -34,7 +34,7 @@ ms.date: 04/11/2024 + [APT2000](apt2000.md): Generic `aapt2` error/warning. + [APT2264](apt2264.md): The system cannot find the file specified. (2). + [APT2265](apt2265.md): The system cannot find the file specified. (2). -+ [APT2266](apt2267.md): Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. ++ [APT2267](apt2267.md): Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. ## JAVAxxxx: Java Tool diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs index f5adb708858..98001409839 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs @@ -135,11 +135,11 @@ public static string APT2265 { } /// - /// Looks up a localized string similar to This could be caused by the project having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2265 for details.. + /// Looks up a localized string similar to This could be caused by the project having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details.. /// - public static string APT2266 { + public static string APT2267 { get { - return ResourceManager.GetString("APT2266", resourceCulture); + return ResourceManager.GetString("APT2267", resourceCulture); } } diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index 32b72759b88..516d56a41b7 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -564,8 +564,8 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla This could be caused by the project having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2265 for details. The following are literal names and should not be translated: - - Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2266 for details. + + Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. The following are literal names and should not be translated: ASCII From e852e1579fd50b1e47af1547cb2e231a05752292 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 09:45:03 +0000 Subject: [PATCH 10/15] Rework to not duplicate code --- Documentation/docs-mobile/messages/apt2267.md | 26 ------------------- Documentation/docs-mobile/messages/index.md | 1 - .../Properties/Resources.Designer.cs | 9 ------- .../Properties/Resources.resx | 5 ---- .../Tasks/Aapt2.cs | 14 +--------- .../Tasks/Aapt2Link.cs | 8 +++--- .../Tasks/Aapt2LinkAssetPack.cs | 4 +-- 7 files changed, 7 insertions(+), 60 deletions(-) delete mode 100644 Documentation/docs-mobile/messages/apt2267.md diff --git a/Documentation/docs-mobile/messages/apt2267.md b/Documentation/docs-mobile/messages/apt2267.md deleted file mode 100644 index 4d74d2a5bf8..00000000000 --- a/Documentation/docs-mobile/messages/apt2267.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: .NET for Android error APT2267 -description: APT2267 error code -ms.date: 04/11/2024 ---- -# .NET for Android error APT2267 - -## Example messages - -```cli -error APT2267: Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. -``` - -## Issue - -The Full Path to the directory you are trying to use as an Asset Directory -contains non-ASCII characters. The `aapt2` tool has a known bug where it cannot traverse directories with non-ASCII characters [1]. -This is commonly caused by users having non-ASCII characters in their usernames, or in the project folders. - -[1] https://issuetracker.google.com/issues/188679588 - -## Solution - -Rename the folder which contains non-ASCII characters to something which only has ASCII characters. If it is your username which has the non-ASCII -characters, the only solution is to move the project somewhere outside of -your user path. Most common solutions is to have a working or sandbox directory off the root of your drive rather than creating projects in `c:\Users\xxx`. diff --git a/Documentation/docs-mobile/messages/index.md b/Documentation/docs-mobile/messages/index.md index e7c6ecdb2cf..73993e4b3e2 100644 --- a/Documentation/docs-mobile/messages/index.md +++ b/Documentation/docs-mobile/messages/index.md @@ -34,7 +34,6 @@ ms.date: 04/11/2024 + [APT2000](apt2000.md): Generic `aapt2` error/warning. + [APT2264](apt2264.md): The system cannot find the file specified. (2). + [APT2265](apt2265.md): The system cannot find the file specified. (2). -+ [APT2267](apt2267.md): Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. ## JAVAxxxx: Java Tool diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs index 98001409839..636e491f4a9 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.Designer.cs @@ -134,15 +134,6 @@ public static string APT2265 { } } - /// - /// Looks up a localized string similar to This could be caused by the project having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details.. - /// - public static string APT2267 { - get { - return ResourceManager.GetString("APT2267", resourceCulture); - } - } - /// /// Looks up a localized string similar to Directory '{0}' is from '{1}'.. /// diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index 516d56a41b7..d58057272af 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -564,11 +564,6 @@ Either change the value in the AndroidManifest.xml to match the $(SupportedOSPla This could be caused by the project having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2265 for details. The following are literal names and should not be translated: - - Asset directories cannot use non-ASCII characters. This could be caused by the directory having non-ASCII characters in its filename or path. See https://learn.microsoft.com/dotnet/android/messages/apt2267 for details. - The following are literal names and should not be translated: -ASCII - Could not AOT the assembly: {0} The abbreviation "AOT" should not be translated. diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs index f5a51835cbd..61060d9f139 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs @@ -22,7 +22,6 @@ namespace Xamarin.Android.Tasks { public abstract class Aapt2 : AsyncTask { private const int MAX_PATH = 260; - private const int ASCII_MAX_CHAR = 127; private static readonly int DefaultMaxAapt2Daemons = 6; protected Dictionary _resource_name_case_map; @@ -62,17 +61,6 @@ public static bool IsInvalidFilename (string path) => /// Source https://github.com/dotnet/runtime/blob/1d1bf92fcf43aa6981804dc53c5174445069c9e4/src/libraries/System.Private.CoreLib/src/System/Char.cs#L91 /// public static bool IsAscii(char c) => (uint)c <= '\x007f'; - /// - /// Returns true if the path has non-ASCII characters. - /// - /// The path to be checked - /// - public static bool IsInvalidDirectoryName (string path) { - foreach (var c in path) - if (!IsAscii(c)) - return true; - return false; - } protected string ResourceDirectoryFullPath (string resourceDirectory) { @@ -254,7 +242,7 @@ static bool IsPathOnlyASCII (string filePath) return true; foreach (var c in filePath) - if (c > ASCII_MAX_CHAR) // cannot use Char.IsAscii cos we are .netstandard2.0 + if (!IsAscii(c)) return false; return true; } diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs index 5b31360937b..333921e57cc 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs @@ -278,9 +278,9 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s if (!string.IsNullOrEmpty (AssetsDirectory)) { var assetDir = GetFullPath (AssetsDirectory.TrimEnd ('\\')); if (Directory.Exists (assetDir)) { - if (IsInvalidDirectoryName (assetDir)) { + if (!IsPathOnlyASCII (assetDir)) { hasAssetsErrors = true; - LogCodedError ("APT2267", Properties.Resources.APT2267, assetDir); + LogCodedError ("APT2265", Properties.Resources.APT2265, assetDir); } cmd.Add ("-A"); cmd.Add (assetDir); @@ -294,9 +294,9 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s var assetDir = GetFullPath (AdditionalAndroidAssetPaths [i].ItemSpec.TrimEnd ('\\')); if (!string.IsNullOrWhiteSpace (assetDir)) { if (Directory.Exists (assetDir)) { - if (IsInvalidDirectoryName (assetDir)) { + if (!IsPathOnlyASCII (assetDir)) { hasAssetsErrors = true; - LogCodedError ("APT2267", Properties.Resources.APT2267, assetDir); + LogCodedError ("APT2265", Properties.Resources.APT2265, assetDir); continue; } cmd.Add ("-A"); diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs index ec7c10ebabc..09d3f490b36 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs @@ -64,8 +64,8 @@ protected string[] GenerateCommandLineCommands (ITaskItem manifest, ITaskItem ou cmd.Add (PackageName); foreach (var assetDirectory in AssetDirectories) { var fullPath = GetFullPath (assetDirectory.ItemSpec); - if (IsInvalidDirectoryName (fullPath)) { - LogCodedError ("APT2267", Properties.Resources.APT2267, fullPath); + if (!IsPathOnlyASCII (fullPath)) { + LogCodedError ("APT2265", Properties.Resources.APT2265, fullPath); continue; } cmd.Add ("-A"); From f9603df234480a33bb33ebb61f8550d6b058d13a Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 09:47:39 +0000 Subject: [PATCH 11/15] formatting --- src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs index 61060d9f139..3e0187ce09c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs @@ -242,7 +242,7 @@ static bool IsPathOnlyASCII (string filePath) return true; foreach (var c in filePath) - if (!IsAscii(c)) + if (!IsAscii (c)) return false; return true; } From 8431a90501f230e933093021f69f6802da930d7a Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 09:47:58 +0000 Subject: [PATCH 12/15] Fix test --- .../Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs index 57da5685942..0f0dc56de2b 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs @@ -149,7 +149,7 @@ public void InvalidAssetDirectoryWithNonASCIIChars () using (var b = CreateApkBuilder (Path.Combine ("temp", "InvalidAssetDirectoryWithNonASCIIChars_Ümläüt", proj.ProjectName))) { b.ThrowOnBuildFailure = false; Assert.IsFalse (b.Build (proj), "{0} should not have built successfully.", proj.ProjectName); - Assert.IsTrue (b.LastBuildOutput.ContainsText ("APT2267"), "Expected APT2267 error not found."); + Assert.IsTrue (b.LastBuildOutput.ContainsText ("APT2265"), "Expected APT2265 error not found."); } } From 94353ee0ed1ff7ad9e368bec0c0584da374a66ab Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 10:58:53 +0000 Subject: [PATCH 13/15] Fix build error --- src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs index 3e0187ce09c..2ac351070a6 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs @@ -236,7 +236,7 @@ static bool IsFilePathToLong (string filePath) return false; } - static bool IsPathOnlyASCII (string filePath) + static protected bool IsPathOnlyASCII (string filePath) { if (!OS.IsWindows) return true; From 4aa287d013c3153bbf5a623a4b6fdb0776bc35f3 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 11:53:27 +0000 Subject: [PATCH 14/15] Only error on WINDOWS --- src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs | 4 ++-- src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs | 2 +- .../Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs index 333921e57cc..4c6397a111c 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs @@ -278,7 +278,7 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s if (!string.IsNullOrEmpty (AssetsDirectory)) { var assetDir = GetFullPath (AssetsDirectory.TrimEnd ('\\')); if (Directory.Exists (assetDir)) { - if (!IsPathOnlyASCII (assetDir)) { + if (OS.IsWindows && !IsPathOnlyASCII (assetDir)) { hasAssetsErrors = true; LogCodedError ("APT2265", Properties.Resources.APT2265, assetDir); } @@ -294,7 +294,7 @@ string [] GenerateCommandLineCommands (string ManifestFile, string currentAbi, s var assetDir = GetFullPath (AdditionalAndroidAssetPaths [i].ItemSpec.TrimEnd ('\\')); if (!string.IsNullOrWhiteSpace (assetDir)) { if (Directory.Exists (assetDir)) { - if (!IsPathOnlyASCII (assetDir)) { + if (OS.IsWindows && !IsPathOnlyASCII (assetDir)) { hasAssetsErrors = true; LogCodedError ("APT2265", Properties.Resources.APT2265, assetDir); continue; diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs index 09d3f490b36..6e6b437a870 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/Aapt2LinkAssetPack.cs @@ -64,7 +64,7 @@ protected string[] GenerateCommandLineCommands (ITaskItem manifest, ITaskItem ou cmd.Add (PackageName); foreach (var assetDirectory in AssetDirectories) { var fullPath = GetFullPath (assetDirectory.ItemSpec); - if (!IsPathOnlyASCII (fullPath)) { + if (OS.IsWindows && !IsPathOnlyASCII (fullPath)) { LogCodedError ("APT2265", Properties.Resources.APT2265, fullPath); continue; } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs index 0f0dc56de2b..30b767f83ba 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs @@ -148,8 +148,8 @@ public void InvalidAssetDirectoryWithNonASCIIChars () }; using (var b = CreateApkBuilder (Path.Combine ("temp", "InvalidAssetDirectoryWithNonASCIIChars_Ümläüt", proj.ProjectName))) { b.ThrowOnBuildFailure = false; - Assert.IsFalse (b.Build (proj), "{0} should not have built successfully.", proj.ProjectName); - Assert.IsTrue (b.LastBuildOutput.ContainsText ("APT2265"), "Expected APT2265 error not found."); + Assert.AreEqual (!IsWindows, b.Build (proj), $"{proj.ProjectName} should {(IsWindows ? "not " : "")}have built successfully."); + Assert.AreEqual (IsWindows, b.LastBuildOutput.ContainsText ("APT2265"), $"APT2265 should {(IsWindows ? "not " : "")}have been raised."); } } From d5ba38743a8a72bb8b3fe1652ea90f1bab3023d5 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Fri, 21 Feb 2025 11:56:52 +0000 Subject: [PATCH 15/15] grrrrr --- .../Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs index 30b767f83ba..87339309d10 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildAssetsTest.cs @@ -149,7 +149,7 @@ public void InvalidAssetDirectoryWithNonASCIIChars () using (var b = CreateApkBuilder (Path.Combine ("temp", "InvalidAssetDirectoryWithNonASCIIChars_Ümläüt", proj.ProjectName))) { b.ThrowOnBuildFailure = false; Assert.AreEqual (!IsWindows, b.Build (proj), $"{proj.ProjectName} should {(IsWindows ? "not " : "")}have built successfully."); - Assert.AreEqual (IsWindows, b.LastBuildOutput.ContainsText ("APT2265"), $"APT2265 should {(IsWindows ? "not " : "")}have been raised."); + Assert.AreEqual (IsWindows, b.LastBuildOutput.ContainsText ("APT2265"), $"APT2265 should {(IsWindows ? "" : "not ")}have been raised."); } }