Skip to content

Commit cc30075

Browse files
committed
fix failure if project path or temp dir contains whitespace
fix https://github.com/enricosada/dotnet-proj-info/issues/2
1 parent 3b169b7 commit cc30075

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

src/dotnet-proj-info/Inspect.fs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ module MSBuild =
2727
| Project of string
2828

2929
let sprintfMsbuildArg a =
30-
//TODO quote
30+
let quote (s: string) =
31+
if s.Contains(" ")
32+
then sprintf "\"%s\"" s
33+
else s
34+
3135
match a with
32-
| Property (k,v) -> sprintf "/p:%s=%s" k v
33-
| Target t -> sprintf "/t:%s" t
36+
| Property (k,v) -> sprintf "/p:%s=%s" k v |> quote
37+
| Target t -> sprintf "/t:%s" t |> quote
3438
| Switch w -> sprintf "/%s" w
35-
| Project w -> w
39+
| Project w -> w |> quote
3640

3741
open MSBuild
3842

src/dotnet-proj-info/Program.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ open System.IO
5050

5151
let runCmd log exePath args =
5252
log (sprintf "running '%s %s'" exePath (args |> String.concat " "))
53-
let cmd = Command.Run(exePath, args |> Array.ofList |> Array.map box)
53+
let cmd = Command.Run(exePath, args |> List.map (fun s -> s.Trim('"')) |> Array.ofList |> Array.map box)
5454

5555
let result = cmd.Result
5656
log "output:"

test/app c1/Program.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Learn more about F# at http://fsharp.org
2+
3+
open System
4+
5+
[<EntryPoint>]
6+
let main argv =
7+
printfn "Hello World from F#!"
8+
0 // return an integer exit code

test/app c1/app c1.fsproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp1.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<Compile Include="Program.fs" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="FSharp.Core" Version="4.1.*" />
14+
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
15+
</ItemGroup>
16+
17+
</Project>

0 commit comments

Comments
 (0)