dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.93k stars 532 forks source link

[XABT] Use a response file for `D8` task. #9546

Open jpobst opened 8 hours ago

jpobst commented 8 hours ago

Fixes: #9515

We have an AndroidX test that adds every package to a single project and tries to build it. If you reference enough of our library bindings NuGet packages, the command line to d8/java gets too long and throws an error:

Command 'build -c Release -bl' failed with exit code 1.
Errors:
MSB6003: The specified task executable "java.exe" could not be run. System.ComponentModel.Win32Exception (206): An error occurred trying to start process 'C:\Program Files (x86)\Android\openjdk\jdk-17.0.8.101-hotspot\bin\java.exe' with working directory 'D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest'. The filename or extension is too long. [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]
MSB6003: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]
MSB6003: at Microsoft.Build.Utilities.ToolTask.StartToolProcess(Process proc) [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]
MSB6003: at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]
MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]
Warnings:
APT2000: warn: removing resource com.companyname.AllPackagesTest:string/action_bar_expand_collapse_button without required default value. [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]
APT2000: warn: removing resource com.companyname.AllPackagesTest:string/action_bar_expand_collapse_button without required default value. [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]
MSB6002: The command-line for the "D8" task is too long. Command-lines longer than 32000 characters are likely to fail. Try reducing the length of the command-line by breaking down the call to "D8" into multiple calls with fewer parameters per call. [D:\a_work\1\s\output\tests\allpackages\android\AllPackagesTest\AllPackagesTest.csproj]

Allow MSBuild to generate a response file for the D8 task to avoid this error.