Skip to content

Space in path causes ClassParse to fail #8049

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
HermanEldering opened this issue Jun 15, 2022 · 7 comments
Closed

Space in path causes ClassParse to fail #8049

HermanEldering opened this issue Jun 15, 2022 · 7 comments
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/android 🤖 s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working

Comments

@HermanEldering
Copy link

Description

When trying to compile a Jar project for Android the compilation fails when the path contains a space. It gives the following output:

1>Building target "_ExportJarToXml" completely.
1>Output file "<mypath>\Release\api.xml" does not exist.
1>Using "ClassParse" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll".
1>Task "ClassParse"
1>  Using: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe
1>  [class-parse] response file: <mypath>\Release\class-parse.rsp
1>  --o="<mypath>\Release\api.xml.class-parse"
1>  "Jars\IOIOLibCore-5.07.jar"
1>  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe @<mypath>\Release\class-parse.rsp 
1>  
1>  Unhandled Exception: System.IO.FileNotFoundException: Could not find file '<my path left of first space>'.
1>     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
1>     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path)
1>     at System.IO.File.OpenText(String path)
1>     at Mono.Options.ResponseFileSource.GetArguments(String value, IEnumerable`1& replacement) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 718
1>     at Mono.Options.OptionSet.AddSource(ArgumentEnumerator ae, String argument) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1094
1>     at Mono.Options.OptionSet.Parse(IEnumerable`1 arguments) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1050
1>     at Xamarin.Android.Tools.App.Main(String[] args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/tools/class-parse/Program.cs:line 61
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.ClassParse.targets(30,5): error MSB6006: "class-parse.exe" exited with code -532462766.
1>Done executing task "ClassParse" -- FAILED.
1>Done building target "_ExportJarToXml" in project "IOIOLibJar.csproj" -- FAILED.

If I run the command given below from the project directory then it doesn't show an error message, and a api.xml.class-parse exists in the obj folder. Note the added quotes for the command line parameter.

"C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe" "@<mypath>\Release\class-parse.rsp"

Unfortunately, running this command manually does not enable building because the xml file needs to be processed to generate api.xml.

Steps to Reproduce

  1. Copy a jar project to a directory which contains a space in the path.
  2. Rebuild the project with Visual Studio

Visual Studio version 17.3 Preview 1.1
.NET 6.0.301

Version with bug

Unknown/Other (please specify)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android (All)

Did you find any workaround?

No response

Relevant log output

1>Building target "_ExportJarToXml" completely.
1>Output file "<mypath>\Release\api.xml" does not exist.
1>Using "ClassParse" task from assembly "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Build.Tasks.dll".
1>Task "ClassParse"
1>  Using: C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe
1>  [class-parse] response file: <mypath>\Release\class-parse.rsp
1>  --o="<mypath>\Release\api.xml.class-parse"
1>  "Jars\IOIOLibCore-5.07.jar"
1>  C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\class-parse.exe @<mypath>\Release\class-parse.rsp 
1>  
1>  Unhandled Exception: System.IO.FileNotFoundException: Could not find file '<my path left of first space>'.
1>     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
1>     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)
1>     at System.IO.StreamReader..ctor(String path)
1>     at System.IO.File.OpenText(String path)
1>     at Mono.Options.ResponseFileSource.GetArguments(String value, IEnumerable`1& replacement) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 718
1>     at Mono.Options.OptionSet.AddSource(ArgumentEnumerator ae, String argument) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1094
1>     at Mono.Options.OptionSet.Parse(IEnumerable`1 arguments) in D:\a\1\s\XPlat\Mono.Options\externals\Options.cs:line 1050
1>     at Xamarin.Android.Tools.App.Main(String[] args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/tools/class-parse/Program.cs:line 61
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.ClassParse.targets(30,5): error MSB6006: "class-parse.exe" exited with code -532462766.
1>Done executing task "ClassParse" -- FAILED.
1>Done building target "_ExportJarToXml" in project "IOIOLibJar.csproj" -- FAILED.
@HermanEldering HermanEldering added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Jun 15, 2022
@jsuarezruiz jsuarezruiz added the area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging label Jun 15, 2022
@jfversluis jfversluis added platform/android 🤖 and removed s/needs-verification Indicates that this issue needs initial verification before further triage will happen labels Jun 15, 2022
@jfversluis
Copy link
Member

@jonathanpeppers ?

@jonathanpeppers
Copy link
Member

@jpobst could this be something introduced by: dotnet/android#6551?

@jpobst
Copy link
Contributor

jpobst commented Jun 15, 2022

Probably, I guess this doesn't automatically quote arguments:

cmd.AppendSwitch ($"@{responseFile}");

I can fix this week.

@jpobst
Copy link
Contributor

jpobst commented Jun 16, 2022

@jonathanpeppers It looks like @dellis1972 fixed this last month in dotnet/android@67ce902.

Does this commit need to be copied to a release branch?

@jonathanpeppers
Copy link
Member

Hmm, so it's combined with this other feature for compiling Java source...

@jpobst would you be able to separate out the fix by itself, and do a PR for release/6.0.4xx?

@HermanEldering
Copy link
Author

@jpobst I've noticed the same issue in the GenerateBindings target. It was also fixed in the commit you've linked. Just thought I'd point that before you separate out changes for this issue. See src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs at line 239/240.

jonathanpeppers pushed a commit to dotnet/android that referenced this issue Jun 17, 2022
Context: #5926
Fixes: dotnet/maui#8049

There was a bug causing response files to not work when trying to bind
Java libraries in a path containing a space, since the CLI argument
given to `class-parse`/`generator` was not properly quoted.

This has been fixed in 67ce902, however this is
a .NET 7 only PR.

Pull the fix out of that PR and port it to the `6.0.4xx` branch so it
will go into a .NET 6 servicing release.
@Eilon Eilon added the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jan 20, 2023
@ghost
Copy link

ghost commented Jan 20, 2023

Hi @HermanEldering. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@ghost ghost closed this as completed Jan 28, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 27, 2023
This issue was closed.
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area-tooling XAML & C# Hot Reload, XAML Editor, Live Visual Tree, Live Preview, Debugging platform/android 🤖 s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants