diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 9e8a716978b..192d43ed35e 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -650,16 +650,19 @@ stages:
displayName: Report dotnet SDK versions
- script: .\Build.cmd $(_kind) -pack -c $(_BuildConfig)
displayName: Initial build and prepare packages.
- - script: dotnet publish -c $(_BuildConfig) -bl:\"./bin/$(_BuildConfig)/net7.0/win-x64/publish/Trimming.binlog\"
+ - script: dotnet publish -c Release -f:net472 -bl:"./artifacts/log/Release/AheadOfTime/SelfContained_Trimming_net472.binlog"
displayName: Build and publish a trim test package.
- workingDirectory: $(Build.SourcesDirectory)/tests/projects/SelfContained_Trimming_Test
+ workingDirectory: $(Build.SourcesDirectory)/tests/AheadOfTime/SelfContained_Trimming_Test
+ - script: dotnet publish -c Release -f:net7.0 -bl:"./artifacts/log/Release/AheadOfTime/SelfContained_Trimming_net7.0.binlog"
+ displayName: Build and publish a trim test package.
+ workingDirectory: $(Build.SourcesDirectory)/tests/AheadOfTime/SelfContained_Trimming_Test
- script: .\check.cmd
displayName: Check the state of the trimmed app.
- workingDirectory: $(Build.SourcesDirectory)/tests/projects/SelfContained_Trimming_Test
+ workingDirectory: $(Build.SourcesDirectory)/tests/AheadOfTime/SelfContained_Trimming_Test
- task: PublishPipelineArtifact@1
displayName: Publish Trim Tests Logs
inputs:
- targetPath: '$(Build.SourcesDirectory)/tests/projects/SelfContained_Trimming_Test/bin/$(_BuildConfig)/net7.0/win-x64/publish'
+ targetPath: './artifacts/log/Release/AheadOfTime'
artifactName: 'Trim Test Logs Attempt $(System.JobAttempt) Logs $(_kind)'
continueOnError: true
condition: always()
diff --git a/tests/AheadOfTime/Directory.Build.props b/tests/AheadOfTime/Directory.Build.props
new file mode 100644
index 00000000000..bb5b23d29d0
--- /dev/null
+++ b/tests/AheadOfTime/Directory.Build.props
@@ -0,0 +1,3 @@
+
+
+
diff --git a/tests/AheadOfTime/Directory.Build.targets b/tests/AheadOfTime/Directory.Build.targets
new file mode 100644
index 00000000000..bb5b23d29d0
--- /dev/null
+++ b/tests/AheadOfTime/Directory.Build.targets
@@ -0,0 +1,3 @@
+
+
+
diff --git a/tests/projects/SelfContained_Trimming_Test/NuGet.Config b/tests/AheadOfTime/NuGet.Config
similarity index 89%
rename from tests/projects/SelfContained_Trimming_Test/NuGet.Config
rename to tests/AheadOfTime/NuGet.Config
index 2a97bd3b1ce..62abe1e410c 100644
--- a/tests/projects/SelfContained_Trimming_Test/NuGet.Config
+++ b/tests/AheadOfTime/NuGet.Config
@@ -5,7 +5,7 @@
-
+
diff --git a/tests/projects/SelfContained_Trimming_Test/Program.fs b/tests/AheadOfTime/Program.fs
similarity index 100%
rename from tests/projects/SelfContained_Trimming_Test/Program.fs
rename to tests/AheadOfTime/Program.fs
diff --git a/tests/projects/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj b/tests/AheadOfTime/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj
similarity index 93%
rename from tests/projects/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj
rename to tests/AheadOfTime/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj
index 06b29764abb..026a3f391a8 100644
--- a/tests/projects/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj
+++ b/tests/AheadOfTime/SelfContained_Trimming_Test/SelfContained_Trimming_Test.fsproj
@@ -2,7 +2,7 @@
Exe
- net7.0
+ net472;net7.0
preview
true
true
@@ -24,7 +24,7 @@
-
+
diff --git a/tests/projects/SelfContained_Trimming_Test/check.cmd b/tests/AheadOfTime/SelfContained_Trimming_Test/check.cmd
similarity index 100%
rename from tests/projects/SelfContained_Trimming_Test/check.cmd
rename to tests/AheadOfTime/SelfContained_Trimming_Test/check.cmd
diff --git a/tests/AheadOfTime/SelfContained_Trimming_Test/check.ps1 b/tests/AheadOfTime/SelfContained_Trimming_Test/check.ps1
new file mode 100644
index 00000000000..5121275bb96
--- /dev/null
+++ b/tests/AheadOfTime/SelfContained_Trimming_Test/check.ps1
@@ -0,0 +1,35 @@
+function CheckTrim($tfm, $expected_len) {
+ Write-Host "Verify trimming ${tfm}: Expected length: ${expected_len}"
+
+ $cwd = Get-Location
+ Set-Location (Join-Path $PSScriptRoot "bin\Release\${tfm}\win-x64\publish\")
+ $output = .\SelfContained_Trimming_Test.exe
+ Set-Location ${cwd}
+
+ # Checking that it is actually running.
+ if (-not ($LASTEXITCODE -eq 0))
+ {
+ Write-Error "Test failed with exit code ${LASTEXITCODE}" -ErrorAction Stop
+ }
+
+ # Checking that the output is as expected.
+ $expected = "All tests passed"
+ if (-not ($output -eq $expected))
+ {
+ Write-Error "Test failed with unexpected output:`nExpected:`n`t${expected}`nActual`n`t${output}" -ErrorAction Stop
+ }
+
+ # Checking that the trimmed FSharp.Core binary is of expected size (needs adjustments if test is updated).
+ $file = Get-Item (Join-Path $PSScriptRoot "bin\Release\${tfm}\win-x64\publish\FSharp.Core.dll")
+ $file_len = $file.Length
+ if (-not ($file_len -eq $expected_len))
+ {
+ Write-Error "Test failed with unexpected ${tfm} - trimmed FSharp.Core length:`nExpected:`n`t${expected_len} Bytes`nActual:`n`t${file_len} Bytes`nEither codegen or trimming logic have changed. Please investigate and update expected dll size or report an issue." -ErrorAction Stop
+ }
+}
+
+# Check net472 trimmed assemblies trimming doesn't work for tfm net472
+### CheckTrim -tfm "net472" -expected_len 287744
+
+# Check net7.0 trimmed assemblies
+CheckTrim -tfm "net7.0" -expected_len 287744
diff --git a/tests/AheadOfTime/buildtools.proj b/tests/AheadOfTime/buildtools.proj
new file mode 100644
index 00000000000..467b217ec02
--- /dev/null
+++ b/tests/AheadOfTime/buildtools.proj
@@ -0,0 +1,32 @@
+
+
+
+ Release
+ $(NoWarn);NU1504
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/projects/SelfContained_Trimming_Test/check.ps1 b/tests/projects/SelfContained_Trimming_Test/check.ps1
deleted file mode 100644
index 0c959cb1715..00000000000
--- a/tests/projects/SelfContained_Trimming_Test/check.ps1
+++ /dev/null
@@ -1,23 +0,0 @@
-$output = .\bin\Release\net7.0\win-x64\publish\SelfContained_Trimming_Test.exe
-
-# Checking that it is actually running.
-if (-not ($LASTEXITCODE -eq 0))
-{
- Write-Error "Test failed with exit code ${LASTEXITCODE}" -ErrorAction Stop
-}
-
-# Checking that the output is as expected.
-$expected = "All tests passed"
-if (-not ($output -eq $expected))
-{
- Write-Error "Test failed with unexpected output:`nExpected:`n`t${expected}`nActual`n`t${output}" -ErrorAction Stop
-}
-
-# Checking that FSharp.Core binary is of expected size (needs adjustments if test is updated).
-$expected_len = 287744 # In bytes
-$file = Get-Item .\bin\Release\net7.0\win-x64\publish\FSharp.Core.dll
-$file_len = $file.Length
-if (-not ($file_len -eq $expected_len))
-{
- Write-Error "Test failed with unexpected FSharp.Core length:`nExpected:`n`t${expected_len} Bytes`nActual:`n`t${file_len} Bytes`nEither codegen or trimming logic have changed. Please investigate and update expected dll size or report an issue." -ErrorAction Stop
-}