Skip to content

Commit 182dbbc

Browse files
committed
Apply changes from VF# Jenkins build activation
1 parent cc57e77 commit 182dbbc

File tree

24 files changed

+503
-328
lines changed

24 files changed

+503
-328
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,8 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
221221
lib/netcore/fsc/bin/
222222

223223
!lib/bootstrap/signed/**/*
224+
*/.fake
225+
/fcs/packages/
226+
*/paket-files/
227+
/fcs/TestResult.xml
228+
/tests/fcs/

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: csharp
2+
sudo: required
23

34
os:
45
- linux
@@ -10,9 +11,6 @@ mono:
1011
- 4.8.0
1112
- 4.4.2
1213

13-
14-
sudo: false
15-
1614
install:
1715

1816
script:
@@ -23,7 +21,6 @@ script:
2321
# This fails because NUnit gives an exception (!!!!)
2422
# - ./fcs/build.sh Test.NetFx
2523
#
26-
# System.IO.FileNotFoundException: Could not load file or assembly 'nunit.engine.api, Version=3.0.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies.
2724
#
2825
# This fails because Nuget packaging doesn't like backslashes in the package file, but Windows does
2926
# - ./fcs/build.sh NuGet

fcs/.paket/Paket.Restore.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
</PropertyGroup>
8585

8686
<!-- Step 3 Restore project specific stuff if required -->
87-
<Warning Condition=" '$(PaketRestoreRequired)' == 'true' " Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
87+
<Message Condition=" '$(PaketRestoreRequired)' == 'true' " Importance="low" Text="Detected a change ('$(PaketRestoreRequiredReason)') in the project file '$(MSBuildProjectFullPath)', calling paket restore" />
8888
<Exec Command='$(PaketCommand) restore --project "$(MSBuildProjectFullPath)"' Condition=" '$(PaketRestoreRequired)' == 'true' " ContinueOnError="false" />
8989

9090
<!-- This shouldn't actually happen, but just to be sure. -->

fcs/.paket/paket.bootstrapper.exe

-27.5 KB
Binary file not shown.

fcs/.paket/paket.exe

62.3 KB
Binary file not shown.

fcs/.paket/paket.targets

Lines changed: 0 additions & 38 deletions
This file was deleted.

fcs/FSharp.Compiler.Service.MSBuild.v12/FSharp.Compiler.Service.MSBuild.v12.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@
8989
</ProjectReference>
9090
</ItemGroup>
9191
<Import Project="$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\Microsoft.FSharp.Targets" />
92-
</Project>
92+
</Project>

fcs/FSharp.Compiler.Service.ProjectCracker/ProjectCracker.fs

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ open System.Diagnostics
88
open System.Text
99
open System.IO
1010
open System
11+
open System.Xml
1112

12-
type ProjectCracker =
13-
static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
14-
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
15-
let properties = defaultArg properties []
16-
let enableLogging = defaultArg enableLogging true
13+
module Utils =
14+
15+
let Convert loadedTimeStamp (originalOpts: ProjectCrackerTool.ProjectOptions) =
1716
let logMap = ref Map.empty
1817

19-
let rec convert (opts: ProjectCrackerTool.ProjectOptions) : FSharpProjectOptions =
18+
let rec convertProject (opts: ProjectCrackerTool.ProjectOptions) =
2019
if not (isNull opts.Error) then failwith opts.Error
2120

22-
let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions
21+
let referencedProjects() = Array.map (fun (a, b) -> a,convertProject b) opts.ReferencedProjectOptions
2322

2423
let sourceFiles, otherOptions =
2524
opts.Options
@@ -41,7 +40,7 @@ type ProjectCracker =
4140
{ ProjectFileName = opts.ProjectFile
4241
SourceFiles = sourceFiles
4342
OtherOptions = otherOptions
44-
ReferencedProjects = referencedProjects
43+
ReferencedProjects = referencedProjects()
4544
IsIncompleteTypeCheckEnvironment = false
4645
UseScriptResolutionRules = false
4746
LoadTime = loadedTimeStamp
@@ -50,6 +49,16 @@ type ProjectCracker =
5049
ExtraProjectInfo = None
5150
Stamp = None }
5251

52+
convertProject originalOpts, !logMap
53+
54+
type ProjectCracker =
55+
56+
static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
57+
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
58+
let properties = defaultArg properties []
59+
let enableLogging = defaultArg enableLogging true
60+
61+
5362
#if NETSTANDARD1_6
5463
let arguments = [|
5564
yield projectFileName
@@ -70,20 +79,47 @@ type ProjectCracker =
7079
let codebase = Path.GetDirectoryName(Uri(typeof<ProjectCracker>.Assembly.CodeBase).LocalPath)
7180

7281
let crackerFilename = Path.Combine(codebase,"FSharp.Compiler.Service.ProjectCrackerTool.exe")
73-
if not (File.Exists crackerFilename) then failwithf "ProjectCracker exe not found at: %s it must be next to the ProjectCracker dll." crackerFilename
82+
if not (File.Exists crackerFilename) then
83+
failwithf "ProjectCracker exe not found at: %s it must be next to the ProjectCracker dll." crackerFilename
84+
7485
let p = new System.Diagnostics.Process()
86+
7587
p.StartInfo.FileName <- crackerFilename
7688
p.StartInfo.Arguments <- arguments.ToString()
7789
p.StartInfo.UseShellExecute <- false
7890
p.StartInfo.CreateNoWindow <- true
7991
p.StartInfo.RedirectStandardOutput <- true
92+
p.StartInfo.RedirectStandardError <- true
93+
94+
let sbOut = StringBuilder()
95+
let sbErr = StringBuilder()
96+
97+
p.ErrorDataReceived.AddHandler(fun _ a -> sbErr.AppendLine a.Data |> ignore)
98+
p.OutputDataReceived.AddHandler(fun _ a -> sbOut.AppendLine a.Data |> ignore)
99+
80100
ignore <| p.Start()
81101

82-
let ser = new DataContractJsonSerializer(typeof<ProjectCrackerTool.ProjectOptions>)
83-
let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> ProjectCrackerTool.ProjectOptions
102+
p.EnableRaisingEvents <- true
103+
p.BeginOutputReadLine()
104+
p.BeginErrorReadLine()
105+
106+
p.WaitForExit()
107+
108+
let crackerOut = sbOut.ToString()
109+
let crackerErr = sbErr.ToString()
110+
111+
let opts =
112+
try
113+
let ser = new DataContractJsonSerializer(typeof<ProjectCrackerTool.ProjectOptions>)
114+
let stringBytes = Encoding.Unicode.GetBytes crackerOut
115+
use ms = new MemoryStream(stringBytes)
116+
ser.ReadObject(ms) :?> ProjectCrackerTool.ProjectOptions
117+
with
118+
exn ->
119+
raise (Exception(sprintf "error parsing ProjectCrackerTool output, stdoutput was:\n%s\n\nstderr was:\n%s" crackerOut crackerErr, exn))
84120
#endif
85121

86-
convert opts, !logMap
122+
Utils.Convert loadedTimeStamp opts
87123

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

fcs/FSharp.Compiler.Service.ProjectCrackerTool/FSharp.Compiler.Service.ProjectCrackerTool.fsproj

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,85 @@
4646
<Compile Include="Program.fs" />
4747
<None Include="App.config" />
4848
<None Include="FSharp.Compiler.Service.ProjectCracker.targets" />
49+
<None Include="paket.references" />
4950
</ItemGroup>
5051
<ItemGroup>
51-
<Reference Include="Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
52-
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Framework.dll</HintPath>
53-
<Private>false</Private>
54-
</Reference>
55-
<Reference Include="Microsoft.Build.Engine, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
56-
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.Engine.dll</HintPath>
57-
<Private>false</Private>
58-
</Reference>
59-
<Reference Include="Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
60-
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v14.0/Microsoft.Build.dll</HintPath>
61-
<Private>false</Private>
62-
</Reference>
63-
<Reference Include="Microsoft.Build.Utilities.v12.0">
64-
<HintPath>$(FSharpSourcesRoot)/../fcs/dependencies/MSBuild.v12.0/Microsoft.Build.Utilities.v12.0.dll</HintPath>
65-
<Private>false</Private>
66-
</Reference>
6752
<Reference Include="mscorlib" />
6853
<Reference Include="System" />
6954
<Reference Include="System.Configuration" />
7055
<Reference Include="System.Core" />
7156
<Reference Include="System.Numerics" />
7257
<Reference Include="System.Runtime.Serialization" />
7358
<Reference Include="System.Xml" />
74-
7559
<!-- we build the nuget against FSHarp.Core 4.4.0.0 instead of our latest to allow use in wider range of F# tools -->
7660
<Reference Include="FSharp.Core">
7761
<HintPath>$(FSharpSourcesRoot)\..\packages\Microsoft.Portable.FSharp.Core.4.1.20\lib\profiles\net40\FSharp.Core.dll</HintPath>
7862
<Private>false</Private>
7963
</Reference>
80-
8164
</ItemGroup>
8265
<Import Project="$(FSharpSourcesRoot)\..\packages\FSharp.Compiler.Tools.4.1.27\tools\Microsoft.FSharp.Targets" />
66+
<Choose>
67+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
68+
<ItemGroup>
69+
<Reference Include="Microsoft.Build">
70+
<HintPath>..\packages\Microsoft.Build\lib\net45\Microsoft.Build.dll</HintPath>
71+
<Private>True</Private>
72+
<Paket>True</Paket>
73+
</Reference>
74+
</ItemGroup>
75+
</When>
76+
</Choose>
77+
<Choose>
78+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
79+
<ItemGroup>
80+
<Reference Include="Microsoft.Build.Engine">
81+
<HintPath>..\packages\Microsoft.Build.Engine\lib\net45\Microsoft.Build.Engine.dll</HintPath>
82+
<Private>True</Private>
83+
<Paket>True</Paket>
84+
</Reference>
85+
</ItemGroup>
86+
</When>
87+
</Choose>
88+
<Choose>
89+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
90+
<ItemGroup>
91+
<Reference Include="Microsoft.Build.Framework">
92+
<HintPath>..\packages\Microsoft.Build.Framework\lib\net45\Microsoft.Build.Framework.dll</HintPath>
93+
<Private>True</Private>
94+
<Paket>True</Paket>
95+
</Reference>
96+
</ItemGroup>
97+
</When>
98+
</Choose>
99+
<Choose>
100+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
101+
<ItemGroup>
102+
<Reference Include="Microsoft.Build.Utilities.Core">
103+
<HintPath>..\packages\Microsoft.Build.Utilities.Core\lib\net45\Microsoft.Build.Utilities.Core.dll</HintPath>
104+
<Private>True</Private>
105+
<Paket>True</Paket>
106+
</Reference>
107+
</ItemGroup>
108+
</When>
109+
</Choose>
110+
<Choose>
111+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6'">
112+
<ItemGroup>
113+
<Reference Include="System.ComponentModel.Composition">
114+
<Paket>True</Paket>
115+
</Reference>
116+
</ItemGroup>
117+
</When>
118+
</Choose>
119+
<Choose>
120+
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.6')">
121+
<ItemGroup>
122+
<Reference Include="System.Threading.Tasks.Dataflow">
123+
<HintPath>..\packages\System.Threading.Tasks.Dataflow\lib\portable-net45+win8+wpa81\System.Threading.Tasks.Dataflow.dll</HintPath>
124+
<Private>True</Private>
125+
<Paket>True</Paket>
126+
</Reference>
127+
</ItemGroup>
128+
</When>
129+
</Choose>
83130
</Project>
Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,46 @@
11
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
22

33
open System
4-
open System.IO
4+
open System.Reflection
55
open System.Runtime.Serialization.Json
66

77
module Program =
88

9-
[<EntryPoint>]
10-
let main argv =
11-
let text = Array.exists (fun (s: string) -> s = "--text") argv
12-
let argv = Array.filter (fun (s: string) -> s <> "--text") argv
9+
#if !DOTNETCORE
10+
let addMSBuildv14BackupResolution () =
11+
let onResolveEvent = new ResolveEventHandler(fun sender evArgs ->
12+
let requestedAssembly = AssemblyName(evArgs.Name)
13+
if requestedAssembly.Name.StartsWith("Microsoft.Build") &&
14+
not (requestedAssembly.Name.EndsWith(".resources")) &&
15+
not (requestedAssembly.Version.ToString().Contains("12.0.0.0"))
16+
then
17+
// If the version of MSBuild that we're using wasn't present on the machine, then
18+
// just revert back to 12.0.0.0 since that's normally installed as part of the .NET
19+
// Framework.
20+
requestedAssembly.Version <- Version("12.0.0.0")
21+
Assembly.Load requestedAssembly
22+
else
23+
null)
24+
AppDomain.CurrentDomain.add_AssemblyResolve(onResolveEvent)
25+
#endif
1326

27+
let crackAndSendOutput asText argv =
1428
let ret, opts = ProjectCrackerTool.crackOpen argv
1529

16-
if text then
30+
if asText then
1731
printfn "%A" opts
1832
else
1933
let ser = new DataContractJsonSerializer(typeof<ProjectOptions>)
2034
ser.WriteObject(Console.OpenStandardOutput(), opts)
2135
ret
36+
37+
38+
[<EntryPoint>][<STAThread>]
39+
let main argv =
40+
let asText = Array.exists (fun (s: string) -> s = "--text") argv
41+
let argv = Array.filter (fun (s: string) -> s <> "--text") argv
42+
43+
#if !DOTNETCORE
44+
addMSBuildv14BackupResolution ()
45+
#endif
46+
crackAndSendOutput asText argv

0 commit comments

Comments
 (0)