Skip to content

Commit db9952e

Browse files
TIHanbaronfel
authored andcommitted
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 a44aa15 commit db9952e

File tree

4 files changed

+66
-17
lines changed

4 files changed

+66
-17
lines changed

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

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

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

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

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

260300
if ($restore -or $build -or $rebuild -or $pack -or $sign -or $publish) {
261-
BuildSolution
301+
if ($noVisualStudio) {
302+
BuildCompiler
303+
} else {
304+
BuildSolution
305+
}
262306
}
263307

264308
if ($build) {
@@ -268,7 +312,7 @@ try {
268312
$desktopTargetFramework = "net472"
269313
$coreclrTargetFramework = "netcoreapp2.1"
270314

271-
if ($testDesktop) {
315+
if ($testDesktop -and -not $noVisualStudio) {
272316
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework
273317
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.LanguageServer.UnitTests\FSharp.Compiler.LanguageServer.UnitTests.fsproj" -targetFramework $desktopTargetFramework
274318
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Build.UnitTests\FSharp.Build.UnitTests.fsproj" -targetFramework $desktopTargetFramework
@@ -284,7 +328,7 @@ try {
284328
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework
285329
}
286330

287-
if ($testFSharpQA) {
331+
if ($testFSharpQA -and -not $noVisualStudio) {
288332
Push-Location "$RepoRoot\tests\fsharpqa\source"
289333
$resultsRoot = "$ArtifactsDir\TestResults\$configuration"
290334
$resultsLog = "test-net40-fsharpqa-results.log"
@@ -303,21 +347,27 @@ try {
303347
}
304348

305349
if ($testFSharpCore) {
306-
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework
350+
if (-not $noVisualStudio) {
351+
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $desktopTargetFramework
352+
}
307353
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Core.UnitTests\FSharp.Core.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
308354
}
309355

310356
if ($testCompiler) {
311-
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework
357+
if (-not $noVisualStudio) {
358+
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $desktopTargetFramework
359+
}
312360
TestUsingNUnit -testProject "$RepoRoot\tests\FSharp.Compiler.UnitTests\FSharp.Compiler.UnitTests.fsproj" -targetFramework $coreclrTargetFramework
313361
}
314362

315363
if ($testCambridge) {
316-
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework
364+
if (-not $noVisualStudio) {
365+
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $desktopTargetFramework
366+
}
317367
TestUsingNUnit -testProject "$RepoRoot\tests\fsharp\FSharpSuite.Tests.fsproj" -targetFramework $coreclrTargetFramework
318368
}
319369

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

eng/build-utils.ps1

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

239239
$dir = Join-Path $ArtifactsDir "Bootstrap"
240240
Remove-Item -re $dir -ErrorAction SilentlyContinue
@@ -247,9 +247,9 @@ function Make-BootstrapBuild() {
247247

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

254254
return $dir
255255
}

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/fsi/fsi.fsproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<OutputType>Exe</OutputType>
77
<TargetFrameworks>net46;netcoreapp2.1</TargetFrameworks>
88
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
9+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' != ''">$(ProtoTargetFramework)</TargetFrameworks>
10+
<TargetFrameworks Condition="'$(ProtoTargetFramework)' == ''">net472;netcoreapp2.1</TargetFrameworks>
911
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp2.1</TargetFrameworks>
1012
<TargetExt>.exe</TargetExt>
1113
<NoWarn>$(NoWarn);45;55;62;75;1204</NoWarn>

0 commit comments

Comments
 (0)