diff --git a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs index 462c749f2dd30ccf9763b1493094ed3ccb972aad..45fab18685bd599f8ed17c75eb2049d320c9f2e8 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs @@ -16,11 +16,17 @@ type ProjectCracker = let enableLogging = defaultArg enableLogging true let logMap = ref Map.empty - let rec convert (opts: Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectOptions) : FSharpProjectOptions = + let rec convert (opts: ProjectCrackerTool.ProjectOptions) : FSharpProjectOptions = + if not (isNull opts.Error) then failwith opts.Error + let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions let sourceFiles, otherOptions = - opts.Options |> Array.partition (fun x -> x.IndexOfAny(Path.GetInvalidPathChars()) = -1 && Path.GetExtension(x).ToLower() = ".fs") + opts.Options + |> Array.partition (fun x -> + let extension = Path.GetExtension(x).ToLower() + x.IndexOfAny(Path.GetInvalidPathChars()) = -1 + && (extension = ".fs" || extension = ".fsi")) let sepChar = Path.DirectorySeparatorChar @@ -73,8 +79,8 @@ type ProjectCracker = p.StartInfo.RedirectStandardOutput <- true ignore <| p.Start() - let ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof) - let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectOptions + let ser = new DataContractJsonSerializer(typeof) + let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> ProjectCrackerTool.ProjectOptions #endif convert opts, !logMap diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs index 34f3aa16e7a75a850e223de33d87141a45b60f40..71cb966fb194dcb507d6e25736b49e86ec575695 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerOptions.fs @@ -7,4 +7,5 @@ type ProjectOptions = Options: string[] ReferencedProjectOptions: (string * ProjectOptions)[] LogOutput: string + Error: string } diff --git a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs index 639d4d0c2b7cef6a60ccd6cff748448aa968e121..9be9c375370a238f7bca005407db8beb6aa18bf6 100644 --- a/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs +++ b/fcs/FSharp.Compiler.Service.ProjectCrackerTool/ProjectCrackerTool.fs @@ -420,7 +420,8 @@ module internal ProjectCrackerTool = let options = { ProjectFile = file Options = Array.ofSeq (parsedProject.Options @ referencedProjectOutputs) ReferencedProjectOptions = referencedProjectOptions - LogOutput = parsedProject.LogOutput } + LogOutput = parsedProject.LogOutput + Error = null } parsedProject.OutputFile, options @@ -465,9 +466,11 @@ module internal ProjectCrackerTool = 2, { ProjectFile = projectFile; Options = [||]; ReferencedProjectOptions = [||]; - LogOutput = e.ToString() } + LogOutput = e.ToString() + Error = e.Message } else 1, { ProjectFile = ""; Options = [||]; ReferencedProjectOptions = [||]; - LogOutput = "At least two arguments required." } + LogOutput = "At least two arguments required." + Error = null } diff --git a/fcs/FSharp.Compiler.Service.sln b/fcs/FSharp.Compiler.Service.sln index e1be7093795f0cfcf5f1752cd9ca0b3d2bc24289..2fe403a3e368e7fd66c19cb31367e8eb0bc976bd 100644 --- a/fcs/FSharp.Compiler.Service.sln +++ b/fcs/FSharp.Compiler.Service.sln @@ -1,13 +1,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26730.8 +VisualStudioVersion = 15.0.26730.16 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{B6B68AE6-E7A4-4D43-9B34-FFA74BFE192B}" ProjectSection(SolutionItems) = preProject build.cmd = build.cmd build.fsx = build.fsx build.sh = build.sh + nuget\FSharp.Compiler.Service.MSBuild.v12.nuspec = nuget\FSharp.Compiler.Service.MSBuild.v12.nuspec nuget\FSharp.Compiler.Service.nuspec = nuget\FSharp.Compiler.Service.nuspec + nuget\FSharp.Compiler.Service.ProjectCracker.nuspec = nuget\FSharp.Compiler.Service.ProjectCracker.nuspec paket.dependencies = paket.dependencies README.md = README.md RELEASE_NOTES.md = RELEASE_NOTES.md diff --git a/fcs/build.fsx b/fcs/build.fsx index 7e2e12f1bee09100a991edd46387ca930e004521..08717a7ab0c63e3504715e3e62b700c4bb1bcfc5 100644 --- a/fcs/build.fsx +++ b/fcs/build.fsx @@ -99,9 +99,9 @@ Target "Test.NetFx" (fun _ -> // -------------------------------------------------------------------------------------- // Build a NuGet package Target "NuGet.NetFx" (fun _ -> - runCmdIn __SOURCE_DIRECTORY__ @"..\.nuget\NuGet.exe" @"pack nuget\FSharp.Compiler.Service.nuspec -OutputDirectory %s" releaseDir - runCmdIn __SOURCE_DIRECTORY__ @"..\.nuget\NuGet.exe" @"pack nuget\FSharp.Compiler.Service.MSBuild.v12.nuspec -OutputDirectory %s" releaseDir - runCmdIn __SOURCE_DIRECTORY__ @"..\.nuget\NuGet.exe" @"pack nuget\FSharp.Compiler.Service.ProjectCracker.nuspec -OutputDirectory %s" releaseDir + runCmdIn __SOURCE_DIRECTORY__ "../.nuget/NuGet.exe" @"pack nuget/FSharp.Compiler.Service.nuspec -OutputDirectory %s" releaseDir + runCmdIn __SOURCE_DIRECTORY__ "../.nuget/NuGet.exe" @"pack nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec -OutputDirectory %s" releaseDir + runCmdIn __SOURCE_DIRECTORY__ "../.nuget/NuGet.exe" @"pack nuget/FSharp.Compiler.Service.ProjectCracker.nuspec -OutputDirectory %s" releaseDir ) diff --git a/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec index ad905b35c0f0f65789735d9e966d6bae63f96b01..4f0ad40b3675d1d8923c55b52072ff94cb28e00a 100644 --- a/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec +++ b/fcs/nuget/FSharp.Compiler.Service.MSBuild.v12.nuspec @@ -2,10 +2,7 @@ FSharp.Compiler.Service.MSBuild.v12 - - Adds legacy MSBuild 12.0 support to the F# compiler services package for - resolving references such as #r "System, Version=4.1.0.0,..." - + Adds legacy MSBuild 12.0 support to the F# compiler services package for resolving references such as #r "System, Version=4.1.0.0,..." en-US false 16.0.1 diff --git a/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec index d8501e860061a25582533e4289b4a6af2607ad40..802173bd826bc8e530fe676348eefd9836eaf383 100644 --- a/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec +++ b/fcs/nuget/FSharp.Compiler.Service.ProjectCracker.nuspec @@ -2,12 +2,7 @@ FSharp.Compiler.Service.ProjectCracker - - The F# compiler services package contains a custom build of the F# compiler that - exposes additional functionality for implementing F# language bindings, additional - tools based on the compiler or refactoring tools. The package also includes F# - interactive service that can be used for embedding F# scripting into your applications. - + The F# compiler services package contains a custom build of the F# compiler that exposes additional functionality for implementing F# language bindings, additional tools based on the compiler or refactoring tools. The package also includes F# interactive service that can be used for embedding F# scripting into your applications. en-US false 16.0.1 diff --git a/fcs/nuget/FSharp.Compiler.Service.nuspec b/fcs/nuget/FSharp.Compiler.Service.nuspec index 0df07c0240aa76f7fbd23b80f528678c5b5668b7..130f3230691f862d612482676223dc2ba2aca435 100644 --- a/fcs/nuget/FSharp.Compiler.Service.nuspec +++ b/fcs/nuget/FSharp.Compiler.Service.nuspec @@ -2,12 +2,7 @@ FSharp.Compiler.Service - - The F# compiler services package contains a custom build of the F# compiler that - exposes additional functionality for implementing F# language bindings, additional - tools based on the compiler or refactoring tools. The package also includes F# - interactive service that can be used for embedding F# scripting into your applications. - + The F# compiler services package contains a custom build of the F# compiler that exposes additional functionality for implementing F# language bindings, additional tools based on the compiler or refactoring tools. The package also includes F# interactive service that can be used for embedding F# scripting into your applications. en-US false 16.0.1 diff --git a/tests/service/ProjectOptionsTests.fs b/tests/service/ProjectOptionsTests.fs index c2cde1672730b8f23555f8ab852df57bc4b0c970..4fddf734b6acf55cd06bbfc11593683f3f59edc3 100644 --- a/tests/service/ProjectOptionsTests.fs +++ b/tests/service/ProjectOptionsTests.fs @@ -137,14 +137,19 @@ let ``Project file parsing -- compile files 2``() = [] let ``Project file parsing -- bad project file``() = let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/Malformed.fsproj") - let log = snd (ProjectCracker.GetProjectOptionsFromProjectFileLogged(f)) - log.[f] |> should contain "Microsoft.Build.Exceptions.InvalidProjectFileException" + try + ProjectCracker.GetProjectOptionsFromProjectFileLogged(f) |> ignore + failwith "Expected exception" + with e -> + Assert.That(e.Message, Contains.Substring "The project file could not be loaded.") [] let ``Project file parsing -- non-existent project file``() = let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/DoesNotExist.fsproj") - let log = snd (ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true)) - log.[f] |> should contain "System.IO.FileNotFoundException" + try + ProjectCracker.GetProjectOptionsFromProjectFileLogged(f, enableLogging=true) |> ignore + with e -> + Assert.That(e.Message, Contains.Substring "Could not find file") [] let ``Project file parsing -- output file``() = @@ -217,6 +222,19 @@ let ``Project file parsing -- Logging``() = else Assert.That(log, Is.StringContaining("""Using "ResolveAssemblyReference" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".""")) +[] +let ``Project file parsing -- FSharpProjectOptions.SourceFiles contains both fs and fsi files``() = + let projectFileName = normalizePath (__SOURCE_DIRECTORY__ + @"/data/FsAndFsiFiles.fsproj") + let options, log = ProjectCracker.GetProjectOptionsFromProjectFileLogged(projectFileName, enableLogging=true) + printfn "%A" log + let expectedSourceFiles = + [| "Test1File2.fsi" + "Test1File2.fs" + "Test1File1.fs" + "Test1File0.fsi" + "Test1File0.fs" |] + Assert.That(options.SourceFiles |> Array.map Path.GetFileName, Is.EqualTo expectedSourceFiles, "source files") + [] let ``Project file parsing -- Full path``() = let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj") diff --git a/tests/service/data/FsAndFsiFiles.fsproj b/tests/service/data/FsAndFsiFiles.fsproj new file mode 100644 index 0000000000000000000000000000000000000000..676918f28f1970afab77fcec106d8f6f1baa700c --- /dev/null +++ b/tests/service/data/FsAndFsiFiles.fsproj @@ -0,0 +1,63 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {116cc2f9-f987-4b3d-915a-34cac04a73da} + Library + Test1 + Test1 + bin\$(Configuration)\ + False + 11 + + + True + full + False + False + DEBUG;TRACE + 3 + x86 + bin\Debug\Test1.xml + + + pdbonly + True + True + TRACE + 3 + x86 + bin\Release\Test1.xml + False + + + + ..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll + + + + + + + + + + + + + + + + + + ..\..\..\packages\NUnit\lib\nunit.framework.dll + True + True + + + + + \ No newline at end of file