Skip to content

Commit 555461b

Browse files
committed
add servergc switch
1 parent c3df746 commit 555461b

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

azure-pipelines-PR.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ stages:
319319
- checkout: self
320320
clean: true
321321

322-
- script: eng\CIBuildNoPublish.cmd -compressallmetadata -buildnorealsig -testDesktop -configuration Release -testBatch $(System.JobPositionInPhase)
322+
- script: eng\CIBuildNoPublish.cmd -compressallmetadata -buildnorealsig -testDesktop -servergc -configuration Release -testBatch $(System.JobPositionInPhase)
323323
env:
324324
FSharp_CacheEvictionImmediate: true
325325
DOTNET_DbgEnableMiniDump: 1
@@ -560,7 +560,7 @@ stages:
560560
- checkout: self
561561
clean: true
562562

563-
- script: eng\CIBuildNoPublish.cmd -compressallmetadata -configuration Release -testDesktop -testBatch $(System.JobPositionInPhase)
563+
- script: eng\CIBuildNoPublish.cmd -compressallmetadata -configuration Release -testDesktop -servergc -testBatch $(System.JobPositionInPhase)
564564
env:
565565
FSharp_CacheEvictionImmediate: true
566566
DOTNET_DbgEnableMiniDump: 1

eng/Build.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ param (
7474
[switch]$compressAllMetadata,
7575
[switch]$buildnorealsig = $true,
7676
[switch]$verifypackageshipstatus = $false,
77+
[switch]$servergc,
7778
[string]$testBatch = "",
7879
[parameter(ValueFromRemainingArguments = $true)][string[]]$properties)
7980

@@ -141,6 +142,7 @@ function Print-Usage() {
141142
Write-Host " -compressAllMetadata Build product with compressed metadata"
142143
Write-Host " -buildnorealsig Build product with realsig- (default use realsig+, where necessary)"
143144
Write-Host " -verifypackageshipstatus Verify whether the packages we are building have already shipped to nuget"
145+
Write-Host " -servergc Enable Server GC in .NET Framework testhosts"
144146
Write-Host ""
145147
Write-Host "Command line arguments starting with '/p:' are passed through to MSBuild."
146148
}
@@ -602,22 +604,23 @@ try {
602604
$script:BuildMessage = "Failure running tests"
603605

604606

607+
# Run Server GC config update once before any desktop-targeted tests
608+
if ($servergc -and ( $testDesktop -or ($testVs -and -not $noVisualStudio) )) {
609+
Write-Host "Ensuring Server GC in .NET Framework testhosts (updating net472 and net472.x86 configs from local .dotnet SDK) ..."
610+
dotnet fsi "$PSScriptRoot\update-testhost-gcserver.fsx"
611+
}
612+
613+
605614
if ($testCoreClr) {
606615
TestUsingMSBuild -testProject "$RepoRoot\FSharp.sln" -targetFramework $script:coreclrTargetFramework
607616
}
608617

609618

610619
if ($testDesktop) {
611-
# Ensure gcServer is enabled in testhost config before desktop tests
612-
Write-Host "Updating testhost config for desktopTargetFramework..."
613-
dotnet fsi "$PSScriptRoot\update-testhost-gcserver.fsx"
614620
TestUsingMSBuild -testProject "$RepoRoot\FSharp.sln" -targetFramework $script:desktopTargetFramework
615621
}
616622

617623
if ($testVs -and -not $noVisualStudio) {
618-
# Ensure gcServer is enabled in testhost config before VS editor desktop tests
619-
Write-Host "Updating testhost config for desktopTargetFramework (testVs)..."
620-
dotnet fsi "$PSScriptRoot\update-testhost-gcserver.fsx"
621624
TestUsingMSBuild -testProject "$RepoRoot\vsintegration\tests\UnitTests\VisualFSharp.UnitTests.fsproj" -targetFramework $script:desktopTargetFramework
622625
}
623626

eng/update-testhost-gcserver.fsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
// Windows-only: Enables gcServer in the local .dotnet SDK testhost app.config files and prints the SDK version.
2-
// What it does:
3-
// 1) Finds the repo-local .dotnet folder by walking up from this script's directory.
4-
// 2) Runs .dotnet\dotnet.exe --version to get the SDK version and prints it.
5-
// 3) Locates both
6-
// - .dotnet\sdk\{version}\TestHostNetFramework\testhost.net472.exe.config and
7-
// - .dotnet\sdk\{version}\TestHostNetFramework\testhost.net472.x86.exe.config
8-
// and ensures <runtime><gcServer enabled="true"/></runtime> is present, then saves the files.
1+
// Windows-only utility for F# build: ensures <gcServer enabled="true"/> in .NET Framework testhost configs.
2+
// - Prints local .dotnet SDK version
3+
// - Updates BOTH AnyCPU and x86 testhost.net472*.exe.config files under the local .dotnet SDK
4+
// - Intended to run ONCE before desktop/VS tests (not per test)
95
// Usage (from repo root): dotnet fsi eng/update-testhost-gcserver.fsx
106

117
open System
@@ -14,7 +10,7 @@ open System.IO
1410

1511
// This script is intended for Windows only
1612
if not (OperatingSystem.IsWindows()) then
17-
eprintfn "Error: This script supports Windows only."
13+
eprintfn "[ServerGC] ERROR: This script supports Windows only."
1814
exit 1
1915

2016
let exeName = "dotnet.exe"
@@ -32,7 +28,7 @@ let startDir = DirectoryInfo(__SOURCE_DIRECTORY__)
3228

3329
match findDotnetRoot startDir with
3430
| None ->
35-
eprintfn "Error: .dotnet folder with %s not found starting from %s" exeName startDir.FullName
31+
eprintfn "[ServerGC] ERROR: .dotnet folder with %s not found starting from %s" exeName startDir.FullName
3632
exit 1
3733
| Some dotnetRoot ->
3834
let dotnetPath = Path.Combine(dotnetRoot, exeName)
@@ -49,26 +45,26 @@ match findDotnetRoot startDir with
4945
use proc = new Process()
5046
proc.StartInfo <- psi
5147
if not (proc.Start()) then
52-
eprintfn "Error: Failed to start %s" dotnetPath
48+
eprintfn "[ServerGC] ERROR: Failed to start %s" dotnetPath
5349
exit 1
5450

5551
let stdOut = proc.StandardOutput.ReadToEnd()
5652
let stdErr = proc.StandardError.ReadToEnd()
5753
proc.WaitForExit()
5854

5955
if proc.ExitCode <> 0 then
60-
eprintfn "Error: %s --version failed with exit code %d" dotnetPath proc.ExitCode
56+
eprintfn "[ServerGC] ERROR: %s --version failed with exit code %d" dotnetPath proc.ExitCode
6157
if not (System.String.IsNullOrWhiteSpace stdErr) then eprintf "%s" stdErr
6258
exit proc.ExitCode
6359
else
6460
let version = stdOut.Trim()
6561
if System.String.IsNullOrWhiteSpace version then
66-
eprintfn "Error: No version output from %s --version" dotnetPath
62+
eprintfn "[ServerGC] ERROR: No version output from %s --version" dotnetPath
6763
if not (System.String.IsNullOrWhiteSpace stdErr) then eprintf "%s" stdErr
6864
exit 1
6965
else
7066
// Print the SDK version
71-
printfn "%s" version
67+
printfn "[ServerGC] Local .dotnet SDK version: %s" version
7268

7369
// Locate both config files and ensure gcServer is enabled
7470
let cfgFileNames =
@@ -107,7 +103,7 @@ match findDotnetRoot startDir with
107103
el.SetAttributeValue(xn "enabled", "true")
108104

109105
doc.Save(path)
110-
printfn "Updated: %s (gcServer enabled=true)" path
106+
printfn "[ServerGC] Updated: %s (gcServer enabled=true)" path
111107
true
112108

113109
let cfgPaths =
@@ -119,7 +115,10 @@ match findDotnetRoot startDir with
119115

120116
if updatedCount = 0 then
121117
// Fail only if none of the expected files were found
122-
eprintfn "Error: None of the expected config files were found:\n%s" (String.Join("\n", cfgPaths))
118+
eprintfn "[ServerGC] ERROR: None of the expected config files were found:\n%s" (String.Join("\n", cfgPaths))
123119
exit 2
124120
else
121+
printfn "[ServerGC] Updated %d config file(s):" updatedCount
122+
for i = 0 to cfgPaths.Length - 1 do
123+
if results.[i] then printfn "[ServerGC] %s" cfgPaths.[i]
125124
exit 0

0 commit comments

Comments
 (0)