Skip to content

Commit 9489f46

Browse files
committed
Update FCS build to using .Net Core only (#7883)
* update runner to netcore runner * build working * release works, start on doc gen * disable docgen until fsharp.formatting is updated and .net core razor available * Add missing manifest file * reenable the linux fcs job * fix bash build script to go to the fcs dir before restore/build * use default targets where appropriate in build definitions * disable macos FCS builds until https://github.com/microsoft/azure-pipelines-image-generation/issues/1351 is merged
1 parent 16f213a commit 9489f46

File tree

12 files changed

+1350
-259
lines changed

12 files changed

+1350
-259
lines changed

fcs/.config/dotnet-tools.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"fake-cli": {
6+
"version": "5.18.3",
7+
"commands": [
8+
"fake"
9+
]
10+
},
11+
"paket": {
12+
"version": "5.236.0",
13+
"commands": [
14+
"paket"
15+
]
16+
}
17+
}
18+
}

fcs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.paket/
2+
build.fsx.lock
23
FSharp.Compiler.Service.Tests/TestResults/*
34
FSharp.Compiler.Service.netstandard/illex.fs
45
FSharp.Compiler.Service.netstandard/ilpars.fs

fcs/.paket/Paket.Restore.targets

Lines changed: 125 additions & 78 deletions
Large diffs are not rendered by default.

fcs/build.cmd

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
setlocal
44
pushd %~dp0%
55

6+
dotnet tool restore
7+
68
if errorlevel 1 (
79
endlocal
810
exit /b %errorlevel%
911
)
1012

11-
powershell -noprofile -executionPolicy RemoteSigned -file "%~dp0\download-paket.ps1"
12-
.paket\paket.exe restore
13+
dotnet paket restore
1314
if errorlevel 1 (
1415
endlocal
1516
exit /b %errorlevel%
@@ -18,7 +19,8 @@ if errorlevel 1 (
1819
:: don't care if this fails
1920
dotnet build-server shutdown >NUL 2>&1
2021

21-
packages\FAKE\tools\FAKE.exe build.fsx %*
22+
dotnet fake build -t %*
23+
2224
if errorlevel 1 (
2325
endlocal
2426
exit /b %errorlevel%

fcs/build.fsx

Lines changed: 62 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,34 @@
11
// --------------------------------------------------------------------------------------
22
// FAKE build script
33
// --------------------------------------------------------------------------------------
4+
#r "paket: groupref Main //"
5+
#load "./.fake/build.fsx/intellisense.fsx"
46

5-
#I "packages/FAKE/tools"
6-
#r "packages/FAKE/tools/FakeLib.dll"
77
open System
88
open System.IO
9-
open Fake
10-
open Fake.AppVeyor
11-
open Fake.ReleaseNotesHelper
12-
13-
#if MONO
14-
// prevent incorrect output encoding (e.g. https://github.com/fsharp/FAKE/issues/1196)
15-
System.Console.OutputEncoding <- System.Text.Encoding.UTF8
16-
CleanDir (__SOURCE_DIRECTORY__ + "/../artifacts/TestResults")
17-
File.WriteAllText(__SOURCE_DIRECTORY__ + "/../artifacts/TestResults/notestsyet.txt","No tests yet")
18-
let isMono = true
19-
#else
20-
let isMono = false
21-
#endif
22-
23-
24-
let dotnetExePath =
9+
open Fake.BuildServer
10+
open Fake.Core
11+
open Fake.DotNet
12+
open Fake.IO
13+
14+
BuildServer.install [ AppVeyor.Installer ]
15+
// --------------------------------------------------------------------------------------
16+
// Utilities
17+
// --------------------------------------------------------------------------------------
18+
19+
let withDotnetExe =
2520
// Build.cmd normally downloads a dotnet cli to: <repo-root>\artifacts\toolset\dotnet
2621
// check if there is one there to avoid downloading an additional one here
2722
let pathToCli = Path.Combine(__SOURCE_DIRECTORY__, @"..\artifacts\toolset\dotnet\dotnet.exe")
2823
if File.Exists(pathToCli) then
29-
pathToCli
24+
(fun opts -> { opts with DotNet.Options.DotNetCliPath = pathToCli })
3025
else
31-
DotNetCli.InstallDotNetSDK "3.0.100"
32-
33-
let runDotnet workingDir args =
34-
let result =
35-
ExecProcess (fun info ->
36-
info.FileName <- dotnetExePath
37-
info.WorkingDirectory <- workingDir
38-
info.Arguments <- args) TimeSpan.MaxValue
39-
40-
if result <> 0 then failwithf "dotnet %s failed" args
41-
42-
let assertExitCodeZero x = if x = 0 then () else failwithf "Command failed with exit code %i" x
43-
44-
let runCmdIn workDir (exe:string) = Printf.ksprintf (fun (args:string) ->
45-
#if MONO
46-
let exe = exe.Replace("\\","/")
47-
let args = args.Replace("\\","/")
48-
printfn "[%s] mono %s %s" workDir exe args
49-
Shell.Exec("mono", sprintf "%s %s" exe args, workDir)
50-
#else
51-
printfn "[%s] %s %s" workDir exe args
52-
Shell.Exec(exe, args, workDir)
53-
#endif
54-
|> assertExitCodeZero
55-
)
26+
DotNet.install (fun cliOpts -> { cliOpts with Version = DotNet.CliVersion.GlobalJson })
27+
28+
let runDotnet workingDir command args =
29+
let result = DotNet.exec (DotNet.Options.withWorkingDirectory workingDir >> withDotnetExe) command args
30+
31+
if result.ExitCode <> 0 then failwithf "dotnet %s failed with errors: %s" args (result.Errors |> String.concat "\n")
5632

5733
// --------------------------------------------------------------------------------------
5834
// The rest of the code is standard F# build script
@@ -61,77 +37,68 @@ let runCmdIn workDir (exe:string) = Printf.ksprintf (fun (args:string) ->
6137
let releaseDir = Path.Combine(__SOURCE_DIRECTORY__, "../artifacts/bin/fcs/Release")
6238

6339
// Read release notes & version info from RELEASE_NOTES.md
64-
let release = LoadReleaseNotes (__SOURCE_DIRECTORY__ + "/RELEASE_NOTES.md")
65-
let isAppVeyorBuild = buildServer = BuildServer.AppVeyor
66-
let isJenkinsBuild = buildServer = BuildServer.Jenkins
40+
let release = ReleaseNotes.load (__SOURCE_DIRECTORY__ + "/RELEASE_NOTES.md")
41+
let isAppVeyorBuild = AppVeyor.detect()
6742
let isVersionTag (tag: string) = Version.TryParse tag |> fst
68-
let hasRepoVersionTag = isAppVeyorBuild && AppVeyorEnvironment.RepoTag && isVersionTag AppVeyorEnvironment.RepoTagName
69-
let assemblyVersion = if hasRepoVersionTag then AppVeyorEnvironment.RepoTagName else release.NugetVersion
43+
let hasRepoVersionTag = isAppVeyorBuild && AppVeyor.Environment.RepoTag && isVersionTag AppVeyor.Environment.RepoTagName
44+
let assemblyVersion = if hasRepoVersionTag then AppVeyor.Environment.RepoTagName else release.NugetVersion
7045

7146
let buildVersion =
7247
if hasRepoVersionTag then assemblyVersion
73-
else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyorEnvironment.BuildNumber
48+
else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyor.Environment.BuildNumber
7449
else assemblyVersion
7550

76-
Target "Clean" (fun _ ->
77-
CleanDir releaseDir
51+
Target.create "Clean" (fun _ ->
52+
Shell.cleanDir releaseDir
7853
)
7954

80-
Target "Restore" (fun _ ->
55+
Target.create "Restore" (fun _ ->
8156
// We assume a paket restore has already been run
82-
runDotnet __SOURCE_DIRECTORY__ "restore ../src/buildtools/buildtools.proj -v n"
83-
runDotnet __SOURCE_DIRECTORY__ "restore FSharp.Compiler.Service.sln -v n"
57+
runDotnet __SOURCE_DIRECTORY__ "restore" "../src/buildtools/buildtools.proj -v n"
58+
runDotnet __SOURCE_DIRECTORY__ "restore" "FSharp.Compiler.Service.sln -v n"
8459
)
8560

86-
Target "BuildVersion" (fun _ ->
61+
Target.create "BuildVersion" (fun _ ->
8762
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore
8863
)
8964

90-
Target "Build" (fun _ ->
91-
runDotnet __SOURCE_DIRECTORY__ "build ../src/buildtools/buildtools.proj -v n -c Proto"
65+
Target.create "Build" (fun _ ->
66+
runDotnet __SOURCE_DIRECTORY__ "build" "../src/buildtools/buildtools.proj -v n -c Proto"
9267
let fslexPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fslex/Proto/netcoreapp2.1/fslex.dll"
9368
let fsyaccPath = __SOURCE_DIRECTORY__ + "/../artifacts/bin/fsyacc/Proto/netcoreapp2.1/fsyacc.dll"
94-
runDotnet __SOURCE_DIRECTORY__ (sprintf "build FSharp.Compiler.Service.sln -v n -c Release /p:FsLexPath=%s /p:FsYaccPath=%s /p:VersionPrefix=%s" fslexPath fsyaccPath assemblyVersion)
69+
runDotnet __SOURCE_DIRECTORY__ "build" (sprintf "FSharp.Compiler.Service.sln -v n -c Release /p:FsLexPath=%s /p:FsYaccPath=%s" fslexPath fsyaccPath)
9570
)
9671

97-
Target "Test" (fun _ ->
72+
Target.create "Test" (fun _ ->
9873
// This project file is used for the netcoreapp2.0 tests to work out reference sets
99-
runDotnet __SOURCE_DIRECTORY__ "build ../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj -v n /restore /p:DisableCompilerRedirection=true"
74+
runDotnet __SOURCE_DIRECTORY__ "build" "../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj -v n /restore /p:DisableCompilerRedirection=true"
10075

10176
// Now run the tests
10277
let logFilePath = Path.Combine(__SOURCE_DIRECTORY__, "..", "artifacts", "TestResults", "Release", "FSharp.Compiler.Service.Test.xml")
103-
runDotnet __SOURCE_DIRECTORY__ (sprintf "test FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj --no-restore --no-build -v n -c Release --test-adapter-path . --logger \"nunit;LogFilePath=%s\"" logFilePath)
78+
runDotnet __SOURCE_DIRECTORY__ "test" (sprintf "FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.Tests.fsproj --no-restore --no-build -v n -c Release --test-adapter-path . --logger \"nunit;LogFilePath=%s\"" logFilePath)
10479
)
10580

106-
// escape a string's content so that it can be passed on the command line
107-
let escapeString (s: string) =
108-
let replaced = s.Replace("\"", "\\\"")
109-
sprintf "\"%s\"" replaced
110-
111-
Target "NuGet" (fun _ ->
112-
let props =
113-
[ "VersionPrefix", release.NugetVersion
114-
"PackageReleaseNotes", release.Notes |> String.concat "\n"]
115-
|> Seq.map (fun (prop, value) -> sprintf "-p:%s=%s" prop (escapeString value))
116-
|> String.concat " "
117-
118-
runDotnet __SOURCE_DIRECTORY__ (sprintf "pack FSharp.Compiler.Service.sln --no-build -v n -c Release %s" props)
81+
Target.create "NuGet" (fun _ ->
82+
DotNet.pack (fun packOpts ->
83+
{ packOpts with
84+
Configuration = DotNet.BuildConfiguration.Release
85+
Common = packOpts.Common |> withDotnetExe |> DotNet.Options.withVerbosity (Some DotNet.Verbosity.Normal)
86+
MSBuildParams = { packOpts.MSBuildParams with
87+
Properties = packOpts.MSBuildParams.Properties @ [ "Version", assemblyVersion; "PackageReleaseNotes", release.Notes |> String.concat "\n" ] }
88+
}) "FSharp.Compiler.Service.sln"
11989
)
12090

121-
Target "GenerateDocsEn" (fun _ ->
122-
executeFSIWithArgs "docsrc/tools" "generate.fsx" [] [] |> ignore
91+
Target.create "GenerateDocsEn" (fun _ ->
92+
runDotnet "docsrc/tools" "fake" "run generate.fsx"
12393
)
12494

125-
Target "GenerateDocsJa" (fun _ ->
126-
executeFSIWithArgs "docsrc/tools" "generate.ja.fsx" [] [] |> ignore
95+
Target.create "GenerateDocsJa" (fun _ ->
96+
runDotnet "docsrc/tools" "fake" "run generate.ja.fsx"
12797
)
12898

129-
Target "PublishNuGet" (fun _ ->
130-
Paket.Push (fun p ->
131-
let apikey =
132-
match getBuildParam "nuget-apikey" with
133-
| s when not (String.IsNullOrWhiteSpace s) -> s
134-
| _ -> getUserInput "Nuget API Key: "
99+
Target.create "PublishNuGet" (fun _ ->
100+
let apikey = Environment.environVarOrDefault "nuget-apikey" (UserInput.getUserPassword "Nuget API Key: ")
101+
Paket.push (fun p ->
135102
{ p with
136103
ApiKey = apikey
137104
WorkingDir = releaseDir })
@@ -140,10 +107,12 @@ Target "PublishNuGet" (fun _ ->
140107
// --------------------------------------------------------------------------------------
141108
// Run all targets by default. Invoke 'build <Target>' to override
142109

143-
Target "Start" DoNothing
144-
Target "Release" DoNothing
145-
Target "GenerateDocs" DoNothing
146-
Target "TestAndNuGet" DoNothing
110+
Target.create "Start" ignore
111+
Target.create "Release" ignore
112+
Target.create "GenerateDocs" ignore
113+
Target.create "TestAndNuGet" ignore
114+
115+
open Fake.Core.TargetOperators
147116

148117
"Start"
149118
=?> ("BuildVersion", isAppVeyorBuild)
@@ -161,21 +130,21 @@ Target "TestAndNuGet" DoNothing
161130

162131
"NuGet"
163132
==> "TestAndNuGet"
164-
133+
165134
"Build"
166135
==> "NuGet"
167136
==> "PublishNuGet"
168137
==> "Release"
169138

170139
"Build"
171-
==> "GenerateDocsEn"
140+
// ==> "GenerateDocsEn"
172141
==> "GenerateDocs"
173142

174143
"Build"
175-
==> "GenerateDocsJa"
144+
// ==> "GenerateDocsJa"
176145
==> "GenerateDocs"
177146

178147
"GenerateDocs"
179148
==> "Release"
180149

181-
RunTargetOrDefault "Build"
150+
Target.runOrDefaultWithArguments "Build"

fcs/build.sh

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
#!/bin/bash
2-
if test "$OS" = "Windows_NT"
3-
then
4-
# use .Net
5-
cmd fcs/build.cmd $@
6-
else
7-
if [[ "$PWD" != *fcs ]]; then
8-
cd fcs
9-
fi
102

11-
# use mono
12-
if [[ ! -e ~/.config/.mono/certs ]]; then
13-
mozroots --import --sync --quiet
14-
fi
3+
# bail out as soon as any single command errors
4+
set -e
155

16-
./download-paket.sh
17-
mono .paket/paket.exe restore
18-
exit_code=$?
19-
if [ $exit_code -ne 0 ]; then
20-
exit $exit_code
21-
fi
22-
23-
mono packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
24-
fi
6+
start_pwd=$PWD
7+
8+
# dotnet tools look in certain paths by default that Just Work when we're in the fcs dir,
9+
# so let's force that here:
10+
cd $(dirname ${BASH_SOURCE[0]})
11+
12+
dotnet tool restore
13+
dotnet paket restore
14+
dotnet fake build -t $@
15+
16+
# but we'll be nice and go back to the start dir at the end
17+
cd $start_pwd

fcs/docsrc/tools/generate.fsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// (the generated documentation is stored in the 'docs' directory)
44
// --------------------------------------------------------------------------------------
55

6+
#r "paket: groupref generate //"
7+
#load "./.fake/generate.fsx/intellisense.fsx"
8+
69
// Binaries that have XML documentation (in a corresponding generated XML file)
710
let referenceBinaries = [ "FSharp.Compiler.Service.dll" ]
811
// Web site location for the generated documentation
@@ -20,15 +23,12 @@ let info =
2023
// For typical project, no changes are needed below
2124
// --------------------------------------------------------------------------------------
2225

23-
#load "../../packages/FSharp.Formatting/FSharp.Formatting.fsx"
24-
#I "../../packages/FAKE/tools"
25-
#r "../../packages/FAKE/tools/FakeLib.dll"
2626
open Fake
2727
open System.IO
28-
open Fake.FileHelper
28+
open Fake.IO.FileSystemOperators
29+
open Fake.IO
30+
open Fake.Core
2931
open FSharp.Literate
30-
open FSharp.MetadataFormat
31-
open FSharp.Formatting.Razor
3232

3333
let root = "."
3434

@@ -49,17 +49,18 @@ let layoutRoots =
4949

5050
// Copy static files and CSS + JS from F# Formatting
5151
let copyFiles () =
52-
CopyRecursive files output true |> Log "Copying file: "
53-
ensureDirectory (output @@ "content")
54-
CopyRecursive (formatting @@ "styles") (output @@ "content") true
55-
|> Log "Copying styles and scripts: "
52+
Shell.copyRecursive files output true
53+
|> Trace.tracefn "Copying file: %A"
54+
Directory.ensure (output @@ "content")
55+
Shell.copyRecursive (formatting @@ "styles") (output @@ "content") true
56+
|> Trace.tracefn "Copying styles and scripts: %A"
5657

5758
let clr = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
5859
let fsfmt = __SOURCE_DIRECTORY__ @@ ".." @@ ".." @@ @"packages" @@ "FSharp.Formatting" @@ "lib" @@ "net40"
5960

6061
// Build API reference from XML comments
6162
let buildReference () =
62-
CleanDir (output @@ "reference")
63+
Shell.cleanDir (output @@ "reference")
6364
for lib in referenceBinaries do
6465
RazorMetadataFormat.Generate
6566
( bin @@ lib, output @@ "reference", layoutRoots,

fcs/download-paket.ps1

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

0 commit comments

Comments
 (0)