Skip to content
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

[tests] trim trailing \ from AndroidSdkDirectory/JavaSdkDirectory #8564

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

jonathanpeppers
Copy link
Member

When running MSBuild tests locally, both of the paths used for:

/p:AndroidSdkDirectory="C:\Some Path\android-sdk\"
/p:JavaSdkDirectory="C:\Some Path\jdk\"

Because the two paths have a trailing \, it appears that MSBuild is escaping the \" giving an error message that we can't build more than one project! Basically, all command-line parsing is failing!

I am unsure what changed, but making this change locally allows me to run the MSBuild tests again.

When running MSBuild tests locally, both of the paths used for:

    /p:AndroidSdkDirectory="C:\Some Path\android-sdk\"
    /p:JavaSdkDirectory="C:\Some Path\jdk\"

Because the two paths have a trailing `\`, it appears that MSBuild is
escaping the `\"` giving an error message that we can't build more than
one project! Basically, all command-line parsing is failing!

I am unsure what changed, but making this change locally allows me to
run the MSBuild tests again.
@@ -154,10 +154,10 @@ List<string> GetDefaultCommandLineArgs (string verb, string target = null, strin
arguments.Add ($"/t:{target}");
}
if (Directory.Exists (AndroidSdkPath)) {
arguments.Add ($"/p:AndroidSdkDirectory=\"{AndroidSdkPath}\"");
arguments.Add ($"/p:AndroidSdkDirectory=\"{AndroidSdkPath.TrimEnd('\\')}\"");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always found that the quotes need to go around the entire /p:foo=foo for it to work consistently.
e.g \"/p:AndroidSdkDirectory={AndroidSdkPath}\"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if it works it works 🤷

Copy link
Member Author

@jonathanpeppers jonathanpeppers Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this (for both the SDK and JDK), but still get the error:

Suggested change
arguments.Add ($"/p:AndroidSdkDirectory=\"{AndroidSdkPath.TrimEnd('\\')}\"");
arguments.Add ($"\"/p:AndroidSdkDirectory={AndroidSdkPath}\"");

I suspect something changed with the arguments here for dotnet build in .NET 9.

@jonathanpeppers jonathanpeppers merged commit 58dbd6d into dotnet:main Dec 6, 2023
45 of 47 checks passed
@jonathanpeppers jonathanpeppers deleted the fix-msbuild-tests branch December 6, 2023 16:55
grendello added a commit that referenced this pull request Dec 6, 2023
* main:
  [tests] trim trailing `\` from AndroidSdkDirectory/JavaSdkDirectory (#8564)
  [Xamarin.Android.Build.Tasks] Update XA5207 for VSCode (#8494)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants