Skip to content

Commit 010bd00

Browse files
authored
Added -noVisualStudio flag for build.cmd. (#7071)
* Added -compiler flag for build. Does not require VS to build. * Renamed -compiler to -noVisualStudio * Minor fix * Trying to fix unix builds * Update DEVGUIDE.md
1 parent 6af64a7 commit 010bd00

File tree

7 files changed

+72
-18
lines changed

7 files changed

+72
-18
lines changed

DEVGUIDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ After you build the first time you can open and use this solution:
5252

5353
If you are just developing the core compiler and library then building ``FSharp.sln`` will be enough.
5454

55+
If you do not have Visual Studio installed and want to simply build the compiler as a .NET Core application, use this:
56+
57+
Build.cmd -noVisualStudio
58+
5559
### Developing the F# Compiler (Linux/macOS)
5660

5761
For Linux/Mac:

eng/Build.ps1

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ param (
5353
[switch]$testVs,
5454
[switch]$testAll,
5555
[string]$officialSkipTests = "false",
56+
[switch]$noVisualStudio,
5657

5758
[parameter(ValueFromRemainingArguments=$true)][string[]]$properties)
5859

@@ -96,6 +97,7 @@ function Print-Usage() {
9697
Write-Host " -procdump Monitor test runs with procdump"
9798
Write-Host " -prepareMachine Prepare machine for CI run, clean up processes after build"
9899
Write-Host " -useGlobalNuGetCache Use global NuGet cache."
100+
Write-Host " -noVisualStudio Only build fsc and fsi as .NET Core applications. No Visual Studio required. '-configuration', '-verbosity', '-norestore', '-rebuild' are supported."
99101
Write-Host ""
100102
Write-Host "Command line arguments starting with '/p:' are passed through to MSBuild."
101103
}
@@ -145,8 +147,19 @@ function Process-Arguments() {
145147
}
146148

147149
function Update-Arguments() {
148-
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.exe")) {
149-
$script:bootstrap = $True
150+
if ($script:noVisualStudio) {
151+
$script:bootstrapTfm = "netcoreapp2.1"
152+
$script:msbuildEngine = "dotnet"
153+
}
154+
155+
if ($bootstrapTfm -eq "netcoreapp2.1") {
156+
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) {
157+
$script:bootstrap = $True
158+
}
159+
} else {
160+
if (-Not (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.exe") -or (Test-Path "$ArtifactsDir\Bootstrap\fsc\fsc.runtimeconfig.json")) {
161+
$script:bootstrap = $True
162+
}
150163
}
151164
}
152165

@@ -227,10 +240,37 @@ function TestUsingNUnit([string] $testProject, [string] $targetFramework) {
227240
$projectName = [System.IO.Path]::GetFileNameWithoutExtension($testProject)
228241
$testLogPath = "$ArtifactsDir\TestResults\$configuration\${projectName}_$targetFramework.xml"
229242
$testBinLogPath = "$LogDir\${projectName}_$targetFramework.binlog"
230-
$args = "test $testProject --no-restore --no-build -c $configuration -f $targetFramework -v n --test-adapter-path . --logger ""nunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath"
243+
$args = "test $testProject -c $configuration -f $targetFramework -v n --test-adapter-path . --logger ""nunit;LogFilePath=$testLogPath"" /bl:$testBinLogPath"
244+
245+
if (-not $noVisualStudio -or $norestore) {
246+
$args += " --no-restore"
247+
}
248+
249+
if (-not $noVisualStudio) {
250+
$args += " --no-build"
251+
}
252+
231253
Exec-Console $dotnetExe $args
232254
}
233255

256+
function BuildCompiler() {
257+
if ($bootstrapTfm -eq "netcoreapp2.1") {
258+
$dotnetPath = InitializeDotNetCli
259+
$dotnetExe = Join-Path $dotnetPath "dotnet.exe"
260+
$fscProject = "$RepoRoot\src\fsharp\fsc\fsc.fsproj"
261+
$fsiProject = "$RepoRoot\src\fsharp\fsi\fsi.fsproj"
262+
263+
$argNoRestore = if ($norestore) { " --no-restore" } else { "" }
264+
$argNoIncremental = if ($rebuild) { " --no-incremental" } else { "" }
265+
266+
$args = "build $fscProject -c $configuration -v $verbosity -f netcoreapp2.1" + $argNoRestore + $argNoIncremental
267+
Exec-Console $dotnetExe $args
268+
269+
$args = "build $fsiProject -c $configuration -v $verbosity -f netcoreapp2.1" + $argNoRestore + $argNoIncremental
270+
Exec-Console $dotnetExe $args
271+
}
272+
}
273+
234274
function Prepare-TempDir() {
235275
Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.props") $TempDir
236276
Copy-Item (Join-Path $RepoRoot "tests\Resources\Directory.Build.targets") $TempDir
@@ -259,7 +299,11 @@ try {
259299
}
260300

261301
if ($restore -or $build -or $rebuild -or $pack -or $sign -or $publish) {
262-
BuildSolution
302+
if ($noVisualStudio) {
303+
BuildCompiler
304+
} else {
305+
BuildSolution
306+
}
263307
}
264308

265309
if ($build) {
@@ -269,7 +313,7 @@ try {
269313
$desktopTargetFramework = "net472"
270314
$coreclrTargetFramework = "netcoreapp2.1"
271315

272-
if ($testDesktop) {
316+
if ($testDesktop -and -not $noVisualStudio) {
273317
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework
274318
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.LanguageServer.UnitTests\FSharp.Compiler.LanguageServer.UnitTests.fsproj" -targetFramework $desktopTargetFramework
275319
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $desktopTargetFramework
@@ -285,7 +329,7 @@ try {
285329
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework
286330
}
287331

288-
if ($testFSharpQA) {
332+
if ($testFSharpQA -and -not $noVisualStudio) {
289333
Push-Location "$RepoRoot\tests\fsharpqa\source"
290334
$resultsRoot = "$ArtifactsDir\TestResults\$configuration"
291335
$resultsLog = "test-net40-fsharpqa-results.log"
@@ -304,21 +348,27 @@ try {
304348
}
305349

306350
if ($testFSharpCore) {
307-
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework
351+
if (-not $noVisualStudio) {
352+
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework
353+
}
308354
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
309355
}
310356

311357
if ($testCompiler) {
312-
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework
358+
if (-not $noVisualStudio) {
359+
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework
360+
}
313361
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
314362
}
315363

316364
if ($testCambridge) {
317-
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework
365+
if (-not $noVisualStudio) {
366+
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework
367+
}
318368
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework
319369
}
320370

321-
if ($testVs) {
371+
if ($testVs -and -not $noVisualStudio) {
322372
TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\GetTypesVS.UnitTests\GetTypesVS.UnitTests.fsproj" -targetFramework $desktopTargetFramework
323373
TestUsingNUnit -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $desktopTargetFramework
324374
}

eng/build-utils.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function Run-MSBuild([string]$projectFilePath, [string]$buildArgs = "", [string]
230230
# Important to not set $script:bootstrapDir here yet as we're actually in the process of
231231
# building the bootstrap.
232232
function Make-BootstrapBuild() {
233-
Write-Host "Building bootstrap compiler"
233+
Write-Host "Building bootstrap '$bootstrapTfm' compiler"
234234

235235
$dir = Join-Path $ArtifactsDir "Bootstrap"
236236
Remove-Item -re $dir -ErrorAction SilentlyContinue
@@ -243,7 +243,7 @@ function Make-BootstrapBuild() {
243243

244244
# prepare compiler
245245
$projectPath = "$RepoRoot\proto.proj"
246-
Run-MSBuild $projectPath "/restore /t:Publish" -logFileName "Bootstrap" -configuration $bootstrapConfiguration
246+
Run-MSBuild $projectPath "/restore /t:Publish /p:TargetFramework=$bootstrapTfm;ProtoTargetFramework=$bootstrapTfm" -logFileName "Bootstrap" -configuration $bootstrapConfiguration
247247
Copy-Item "$ArtifactsDir\bin\fsc\$bootstrapConfiguration\$bootstrapTfm\publish" -Destination "$dir\fsc" -Force -Recurse
248248
Copy-Item "$ArtifactsDir\bin\fsi\$bootstrapConfiguration\$bootstrapTfm\publish" -Destination "$dir\fsi" -Force -Recurse
249249

proto.proj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77

88
<ItemGroup>
99
<Projects Include="src\fsharp\FSharp.Build\FSharp.Build.fsproj">
10-
<AdditionalProperties Condition="'$(OS)' != 'Unix'">TargetFramework=net472</AdditionalProperties>
1110
<AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties>
1211
</Projects>
1312
<Projects Include="src\fsharp\fsc\fsc.fsproj">
14-
<AdditionalProperties Condition="'$(OS)' != 'Unix'">TargetFramework=net472</AdditionalProperties>
1513
<AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties>
1614
</Projects>
1715
<Projects Include="src\fsharp\fsi\fsi.fsproj">
18-
<AdditionalProperties Condition="'$(OS)' != 'Unix'">TargetFramework=net472</AdditionalProperties>
1916
<AdditionalProperties Condition="'$(OS)' == 'Unix'">TargetFramework=netcoreapp2.1</AdditionalProperties>
2017
</Projects>
2118
</ItemGroup>

src/fsharp/FSharp.Build/FSharp.Build.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
<PropertyGroup>
66
<OutputType>Library</OutputType>
7-
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
7+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
8+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp2.1</TargetFrameworks>
89
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
910
<AssemblyName>FSharp.Build</AssemblyName>
1011
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>

src/fsharp/fsc/fsc.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
7-
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
7+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
8+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp2.1</TargetFrameworks>
89
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
910
<TargetExt>.exe</TargetExt>
1011
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>

src/fsharp/fsi/fsi.fsproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
<PropertyGroup>
66
<OutputType>Exe</OutputType>
7-
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
7+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
8+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp2.1</TargetFrameworks>
89
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
910
<TargetExt>.exe</TargetExt>
1011
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>

0 commit comments

Comments
 (0)