提交 c76b29ea 编写于 作者: D Don Syme 提交者: GitHub

cherry pick two PRs from FCS (#3687)

* fix assembly reference

* remove line endings from all *.nuspec files

* ProjectCracker returns *.fsi files in FSharpProjectOptions.SourceFiles array (in addition to *.fs files, in right order)

* ProjectCracker raises exception if ProjectCrackerTool returns non null ProjectCrackerOptions.Error (new field)

* fix build on linux

* fix a test

* slashes

* revert slashes

* Update FSharp.Compiler.Service.ProjectCracker.nuspec
上级 9893e723
......@@ -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<Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectOptions>)
let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool.ProjectOptions
let ser = new DataContractJsonSerializer(typeof<ProjectCrackerTool.ProjectOptions>)
let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> ProjectCrackerTool.ProjectOptions
#endif
convert opts, !logMap
......
......@@ -7,4 +7,5 @@ type ProjectOptions =
Options: string[]
ReferencedProjectOptions: (string * ProjectOptions)[]
LogOutput: string
Error: string
}
......@@ -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 }
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
......
......@@ -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
)
......
......@@ -2,10 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>FSharp.Compiler.Service.MSBuild.v12</id>
<description>
Adds legacy MSBuild 12.0 support to the F# compiler services package for
resolving references such as #r "System, Version=4.1.0.0,..."
</description>
<description>Adds legacy MSBuild 12.0 support to the F# compiler services package for resolving references such as #r "System, Version=4.1.0.0,..."</description>
<language>en-US</language>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<version>16.0.1</version>
......
......@@ -2,12 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>FSharp.Compiler.Service.ProjectCracker</id>
<description>
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.
</description>
<description>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.</description>
<language>en-US</language>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<version>16.0.1</version>
......
......@@ -2,12 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>FSharp.Compiler.Service</id>
<description>
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.
</description>
<description>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.</description>
<language>en-US</language>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<version>16.0.1</version>
......
......@@ -137,14 +137,19 @@ let ``Project file parsing -- compile files 2``() =
[<Test>]
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.")
[<Test>]
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")
[<Test>]
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"."""))
[<Test>]
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")
[<Test>]
let ``Project file parsing -- Full path``() =
let f = normalizePath (__SOURCE_DIRECTORY__ + @"/data/ToolsVersion12.fsproj")
......
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{116cc2f9-f987-4b3d-915a-34cac04a73da}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Test1</RootNamespace>
<AssemblyName>Test1</AssemblyName>
<OutputPath>bin\$(Configuration)\</OutputPath>
<UsePartialTypes>False</UsePartialTypes>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<Tailcalls>False</Tailcalls>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Debug\Test1.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
<Optimize>True</Optimize>
<Tailcalls>True</Tailcalls>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<DocumentationFile>bin\Release\Test1.xml</DocumentationFile>
<DebugSymbols>False</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Reference Include="FSharp.Core">
<HintPath>..\..\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Test1File2.fsi" />
<Compile Include="Test1File2.fs" />
<Compile Include="Test1File1.fs" />
<Compile Include="Test1File0.fsi" />
<Compile Include="Test1File0.fs" />
</ItemGroup>
<Import Project="..\..\..\packages\FSharp.Compiler.Tools.4.1.23\tools\Microsoft.FSharp.Targets" />
<Choose>
<When Condition="($(TargetFrameworkIdentifier) == '.NETStandard' And $(TargetFrameworkVersion) == 'v1.6') Or ($(TargetFrameworkIdentifier) == '.NETCoreApp' And $(TargetFrameworkVersion) == 'v1.0') Or ($(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5')">
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\..\..\packages\NUnit\lib\nunit.framework.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册