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

Problem calling Tool with two AbsolutePath's containing spaces. #1376

Open
soeren-bech opened this issue Apr 30, 2024 · 2 comments
Open

Problem calling Tool with two AbsolutePath's containing spaces. #1376

soeren-bech opened this issue Apr 30, 2024 · 2 comments
Labels

Comments

@soeren-bech
Copy link

soeren-bech commented Apr 30, 2024

Usage Information

Nuke 8.0.0 / SDK 8.0.200 / Net8.0 / Windows 10 Pro 22H2

Description

I have many Nuke scripts where this works with Tools like Git.
But in this particular case, I use a Tool instantiated with ToolResolver.GetTool, and it gets the parameters all wrong.

Reproduction Steps

My Build project is in a path with spaces in one directory name (C:\projects\Nuke test). In real life the tool is an exe we built ourselves, but for the demo, I use xcopy.exe as a Tool and have the following code:

        Tool xcopy = ToolResolver.GetTool((AbsolutePath)@"C:" / "Windows" / "System32" / "xcopy.exe");
        xcopy($"{RootDirectory / "test.ps1"} {RootDirectory / "test.ps2"}");

Expected Behavior

I would expect Nuke to call:
C:\Windows\System32\xcopy.exe "C:\projects\Nuke Test\test.ps1" "C:\projects\Nuke Test\test.ps2"

Actual Behavior

Nuke calls
C:\Windows\System32\xcopy.exe C:\projects\Nuke Test\test.ps1" "C:\projects\Nuke Test\test.ps2

Nuke.Common.Tooling.ProcessException: Process 'xcopy.exe' exited with code 4.

C:\Windows\System32\xcopy.exe C:\projects\Nuke Test\test.ps1" "C:\projects\Nuke Test\test.ps2
@ C:\projects\Nuke Test
Error output:
Invalid number of parameters

Regression?

I don't know, but I often use Tool with paths including spaces, just not from ToolResolver.GetTool()

Known Workarounds

No response

Could you help with a pull-request?

No

@soeren-bech
Copy link
Author

The problem is that both parameters have a space in their path.
If only one has a space in the path, it works fine.

@soeren-bech
Copy link
Author

soeren-bech commented May 4, 2024

In the Nuke.Tooling.Tests Project, extend the ArgumentStringHandlerTest with this Fact:
[Fact]
public void TestAbsolutePathsWithSpaces()
{
ArgsToString($"{(AbsolutePath)"C:" / "Some dir" / "file1.sh"} {(AbsolutePath)"C:" / "Some dir" / "file2.sh"}").Should().Be(""C:\Some dir\file1.sh" "C:\Some dir\file2.sh"");
}

...and it will fail due to the extra TrimMatchingDoubleQuotes() in ArgumentStringHandler.ToStringAndClear()

@soeren-bech soeren-bech changed the title Problem calling Tool with AbsolutePath containing spaces. Problem calling Tool with two AbsolutePath's containing spaces. May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant