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

Fix #992 test failure when space in temp path. #1076

Merged
merged 2 commits into from
Jan 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/app/FakeLib/CscHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,22 @@ let cscExe toolPath (srcFiles : string list) (opts : string list) : int =
/// Target = ...
/// ... })
let csc (setParams : CscParams -> CscParams) (inputFiles : string list) : int =
let inputFiles = inputFiles |> Seq.toList
// Helper to quote a path with spaces in it, if not already quoted. See https://github.com/fsharp/FAKE/issues/992
let ensureTrimQuotedPath (path : string) =
Copy link
Member

Choose a reason for hiding this comment

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

Can we put this in one of the other helpers? Maybe we already have something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not see a helper for this. My search for ""%s"" yielded a handful of other places doing this. I will add a helper function trimAndEnsureQuotedIfRequired to the FileSystemHelper.fs.

Copy link
Member

Choose a reason for hiding this comment

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

Thx.
On Jan 16, 2016 2:49 PM, "Ben Taylor" [email protected] wrote:

In src/app/FakeLib/CscHelper.fs
#1076 (comment):

@@ -78,11 +78,22 @@ let cscExe toolPath (srcFiles : string list) (opts : string list) : int =
/// Target = ...
/// ... })
let csc (setParams : CscParams -> CscParams) (inputFiles : string list) : int =

  • let inputFiles = inputFiles |> Seq.toList
  • // Helper to quote a path with spaces in it, if not already quoted. See Build error locally #992
  • let ensureTrimQuotedPath (path : string) =

I could not see a helper for this. My search for ""%s"" yielded a
handful of other places doing this. I will add a helper function
trimAndEnsureQuotedIfRequired to the FileSystemHelper.fs.


Reply to this email directly or view it on GitHub
https://github.com/fsharp/FAKE/pull/1076/files#r49931969.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I'm hesitant about making this a general function. Digging around, this is not as simple as it first appears. Might be better to leave it local to the csc function. It is already local in the other places.

// Sensitive to being backwards compatible with people that are using
// Csc AND quoting their paths. Only quote if space in path and quotes not detected.
// MAYBE this should go in the FileSystemHelper module?
let path = path.Trim()
if path.Contains(" ") then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking this should probably be trimmed. Currently we could double quote a path that is already quoted, but book ended with whitespace.

if (path.StartsWith("\"") && path.EndsWith("\"")) || (path.StartsWith("'") && path.EndsWith("'")) then path
else sprintf "\"%s\"" path
else path

let inputFiles = inputFiles |> Seq.map ensureTrimQuotedPath |> Seq.toList
let taskDesc = inputFiles |> separated ", "
let cscParams = setParams CscParams.Default

let output = if cscParams.Output <> "" then [sprintf "/out:%s" cscParams.Output] else []
let output = if cscParams.Output <> "" then [sprintf "/out:%s" (ensureTrimQuotedPath cscParams.Output)] else []
let target =
match cscParams.Target with
| Exe -> [ "/target:exe" ]
Expand All @@ -98,7 +109,7 @@ let csc (setParams : CscParams -> CscParams) (inputFiles : string list) : int =
| AnyCpu -> [ "/platform:anycpu" ]
let references =
cscParams.References
|> List.map (fun r -> sprintf "/reference:%s" r)
|> List.map (ensureTrimQuotedPath >> (sprintf "/reference:%s"))
let debug = if cscParams.Debug then [ "/debug" ] else []
let argList =
output @ target @ platform @ references @ debug @ cscParams.OtherParams
Expand Down