Skip to content

Commit 244d684

Browse files
committed
Provide log output for all projects parsed
Previously only the top project was available. Also fix NuGet package
1 parent 94e5425 commit 244d684

File tree

6 files changed

+40
-32
lines changed

6 files changed

+40
-32
lines changed

nuget/projectcracker.template

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ iconurl https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.p
1212
tags
1313
F#, fsharp, msbuild, editor
1414
files
15-
../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerSub.exe ==> lib/net45
16-
../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerSub.?db ==> lib/net45
17-
../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerSub.dll.?db ==> lib/net45
18-
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll ==> lib/net45
15+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.Exe.exe ==> lib/net45
16+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.Exe.?db ==> lib/net45
17+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.Exe.exe.?db ==> lib/net45
18+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll ==> lib/net45
1919
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.XML ==> lib/net45
2020
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.?db ==> lib/net45
2121
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll.?db ==> lib/net45

src/fsharp/FSharp.Compiler.Service.ProjectCracker.Exe/FSharp.Compiler.Service.ProjectCracker.Exe.fsproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,26 @@
1717
<NoWarn>$(NoWarn);40</NoWarn>
1818
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1919
<Name>FSharp.Compiler.Service.ProjectCracker.Exe</Name>
20+
<OutputPath>..\..\..\bin\$(TargetFrameworkVersion)</OutputPath>
21+
<DocumentationFile>..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.ProjectCracker.Exe.XML</DocumentationFile>
2022
</PropertyGroup>
2123
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2224
<DebugSymbols>true</DebugSymbols>
2325
<DebugType>full</DebugType>
2426
<Optimize>false</Optimize>
2527
<Tailcalls>false</Tailcalls>
26-
<OutputPath>bin\Debug\</OutputPath>
2728
<DefineConstants>DEBUG;TRACE</DefineConstants>
2829
<WarningLevel>3</WarningLevel>
2930
<PlatformTarget>AnyCPU</PlatformTarget>
30-
<DocumentationFile>bin\Debug\FSharp.Compiler.Service.ProjectCracker.Exe.XML</DocumentationFile>
3131
<Prefer32Bit>true</Prefer32Bit>
3232
</PropertyGroup>
3333
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3434
<DebugType>pdbonly</DebugType>
3535
<Optimize>true</Optimize>
3636
<Tailcalls>true</Tailcalls>
37-
<OutputPath>bin\Release\</OutputPath>
3837
<DefineConstants>TRACE</DefineConstants>
3938
<WarningLevel>3</WarningLevel>
4039
<PlatformTarget>AnyCPU</PlatformTarget>
41-
<DocumentationFile>bin\Release\FSharp.Compiler.Service.ProjectCracker.Exe.XML</DocumentationFile>
4240
<Prefer32Bit>true</Prefer32Bit>
4341
</PropertyGroup>
4442
<PropertyGroup>

src/fsharp/FSharp.Compiler.Service.ProjectCracker.Exe/Program.fs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -412,20 +412,26 @@ module Program =
412412
let argv = Array.filter (fun (s: string) -> s <> "--text") argv
413413

414414
let ret, opts =
415-
try
416-
addMSBuildv14BackupResolution ()
417-
if argv.Length >= 2 then
418-
let projectFile = argv.[0]
419-
let enableLogging = match Boolean.TryParse(argv.[1]) with
420-
| true, true -> true
421-
| _ -> false
422-
let props = pairs (List.ofArray argv.[2..])
423-
let opts = getOptions argv.[0] enableLogging props
424-
0, opts
425-
else
426-
1, { ProjectFile = ""; Options = [||]; ReferencedProjectOptions = [||]; LogOutput = "At least two arguments required." }
427-
with e ->
428-
2, { ProjectFile = ""; Options = [||]; ReferencedProjectOptions = [||]; LogOutput = e.ToString() }
415+
if argv.Length >= 2 then
416+
let projectFile = argv.[0]
417+
let enableLogging = match Boolean.TryParse(argv.[1]) with
418+
| true, true -> true
419+
| _ -> false
420+
try
421+
addMSBuildv14BackupResolution ()
422+
let props = pairs (List.ofArray argv.[2..])
423+
let opts = getOptions argv.[0] enableLogging props
424+
0, opts
425+
with e ->
426+
2, { ProjectFile = projectFile;
427+
Options = [||];
428+
ReferencedProjectOptions = [||];
429+
LogOutput = e.ToString() }
430+
else
431+
1, { ProjectFile = "";
432+
Options = [||];
433+
ReferencedProjectOptions = [||];
434+
LogOutput = "At least two arguments required." }
429435

430436
if text then
431437
printfn "%A" opts

src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,26 @@
1313
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\</SolutionDir>
1414
<TargetFSharpCoreVersion>4.3.0.0</TargetFSharpCoreVersion>
1515
<Name>FSharp.Compiler.Service.ProjectCracker</Name>
16+
<OutputPath>..\..\..\bin\$(TargetFrameworkVersion)</OutputPath>
17+
<DocumentationFile>..\..\..\bin\$(TargetFrameworkVersion)\FSharp.Compiler.Service.ProjectCracker.XML</DocumentationFile>
1618
</PropertyGroup>
1719
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1820
<DebugSymbols>true</DebugSymbols>
1921
<DebugType>full</DebugType>
2022
<Optimize>false</Optimize>
2123
<Tailcalls>false</Tailcalls>
22-
<OutputPath>bin\Debug\</OutputPath>
2324
<DefineConstants>DEBUG;TRACE</DefineConstants>
2425
<WarningLevel>3</WarningLevel>
2526
<PlatformTarget>AnyCPU</PlatformTarget>
26-
<DocumentationFile>bin\Debug\FSharp.Compiler.Service.ProjectCracker.XML</DocumentationFile>
2727
<Prefer32Bit>true</Prefer32Bit>
2828
</PropertyGroup>
2929
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3030
<DebugType>pdbonly</DebugType>
3131
<Optimize>true</Optimize>
3232
<Tailcalls>true</Tailcalls>
33-
<OutputPath>bin\Release\</OutputPath>
3433
<DefineConstants>TRACE</DefineConstants>
3534
<WarningLevel>3</WarningLevel>
3635
<PlatformTarget>AnyCPU</PlatformTarget>
37-
<DocumentationFile>bin\Release\FSharp.Compiler.Service.ProjectCracker.XML</DocumentationFile>
3836
<Prefer32Bit>true</Prefer32Bit>
3937
</PropertyGroup>
4038
<ItemGroup>

src/fsharp/FSharp.Compiler.Service.ProjectCracker/Program.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ type ProjectCracker =
1414
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
1515
let properties = defaultArg properties []
1616
let enableLogging = defaultArg enableLogging false
17+
let logMap = ref Map.empty
1718

1819
let rec convert (opts: FSharp.Compiler.Service.ProjectCracker.Exe.ProjectOptions) : FSharpProjectOptions =
1920
let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions
21+
logMap := Map.add opts.ProjectFile opts.LogOutput !logMap
2022
{ ProjectFileName = opts.ProjectFile
2123
ProjectFileNames = [| |]
2224
OtherOptions = opts.Options
@@ -45,7 +47,7 @@ type ProjectCracker =
4547
let opts = fmt.Deserialize(p.StandardOutput.BaseStream) :?> FSharp.Compiler.Service.ProjectCracker.Exe.ProjectOptions
4648
p.WaitForExit()
4749

48-
convert opts, opts.LogOutput
50+
convert opts, !logMap
4951

5052
static member GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) =
5153
fst (ProjectCracker.GetProjectOptionsFromProjectFileLogged(projectFileName, ?properties=properties, ?loadedTimeStamp=loadedTimeStamp))

tests/service/ProjectOptionsTests.fs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ let ``Project file parsing -- compile files 2``() =
125125

126126
[<Test>]
127127
let ``Project file parsing -- bad project file``() =
128-
let log = snd (ProjectCracker.GetProjectOptionsFromProjectFileLogged(__SOURCE_DIRECTORY__ + @"/data/Malformed.fsproj", enableLogging=true))
129-
log |> should contain "Microsoft.Build.Exceptions.InvalidProjectFileException"
128+
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/Malformed.fsproj")
129+
let log = snd (ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true))
130+
log.[f] |> should contain "Microsoft.Build.Exceptions.InvalidProjectFileException"
130131

131132
[<Test>]
132133
let ``Project file parsing -- non-existent project file``() =
133-
let log = snd (ProjectCracker.GetProjectOptionsFromProjectFileLogged(__SOURCE_DIRECTORY__ + @"/data/DoesNotExist.fsproj", enableLogging=true))
134-
log |> should contain "System.IO.FileNotFoundException"
134+
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/DoesNotExist.fsproj")
135+
let log = snd (ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true))
136+
log.[f] |> should contain "System.IO.FileNotFoundException"
135137

136138
[<Test>]
137139
let ``Project file parsing -- output file``() =
@@ -194,7 +196,9 @@ let ``Project file parsing -- Tools Version 12``() =
194196

195197
[<Test>]
196198
let ``Project file parsing -- Logging``() =
197-
let p, log = ProjectCracker.GetProjectOptionsFromProjectFileLogged(__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj", enableLogging=true)
199+
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
200+
let p, logMap = ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true)
201+
let log = logMap.[f]
198202

199203
if runningOnMono then
200204
Assert.That(log, Is.StringContaining("Reference System.Core resolved"))

0 commit comments

Comments
 (0)