-
Notifications
You must be signed in to change notification settings - Fork 581
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
Fake.Tools.Octo creates invalid command line args #2464
Comments
Welcome to the FAKE community! Thank you so much for creating your first issue and therefore improving the project! |
Yes indeed, thanks for the analysis! That module needs some updates, it needs to use the latest arguments parsing APIs so things like this cannot happen anymore. |
Are you referring to what's described in https://fake.build/apidocs/v5/fake-core-argumentsmodule.html and https://fake.build/core-process.html? |
@CiaranMacCarthaigh Yes indeed. |
I'll have a crack at it. |
@CiaranMacCarthaigh Pretty sure this was due to my PR and I think I fixed it here it is only a quick fix instead of porting tot he new arguments module. Sorry you ran into the bug! |
I guess this has been solved. |
Description
On Windows, when using Fake.Tools.Octo to push a package to Octopus, the command line arguments are not correctly constructed, causing Octopus to fail.
Repro steps
Ensure that you have
dotnet-octo.exe
in a valid path.Call
Fake.Tools.Octo.push
with one package. An example is shown:Expected behavior
Octopus correctly parses the command line options.
Actual behavior
Octopus cannot parse the command line options and returns an error:
Unrecognized command arguments: --package=valid-file-path
Related information
Known workarounds
This issue does not appear in certain earlier versions of Fake.Tools.Octo (such as 5.12). I don't know which versions are affected, I haven't tried to reproduce them.
Probable cause and possible solution
From what I've read of the code, what happens is roughly:
Octo takes the packages and converts the collection into a string of the format:
--package=valid-file-path
. Each of them are separated by a space character. This is done in the functionstringListParam
. However, it also adds a space character before the first item. Unless the collection is empty, the first character in the resultant string is always a space.Eventually, when preparing the command line to start the process,
CmdLineParsing.windowsArgvToCommandLine
will iterate through the arguments provided. Because this packages argument has a space as the first character, it wraps it in double quotations, to account for the space. The string it creates is then:push " --package=valid-file-path" --server=octopusServer --apikey=ABC123456
which is invalid for Octopus.
If the string returned by
stringListParam
does not have this starting space then windowsArgvToCommandLine will return:push --package=valid-file-path --server=octopusServer --apikey=ABC123456
which is valid for Octopus.
A possible solution is to Trim the string that comes out of
stringListParam
, to remove leading whitespace. This will only patch over the problem, for one package. Supplying more than one package will result in a command line like:push "--package=valid-file-path-1 --package=valid-file-path-2 --package=valid-file-path-3" --server=octopusServer --apikey=ABC123456
which is also invalid.
The text was updated successfully, but these errors were encountered: