Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 902d5f6

Browse files
committedFeb 13, 2024
Add PS1 to run test app
1 parent e0e1153 commit 902d5f6

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed
 

‎projects/AotCompatibility.TestApp/AotCompatibility.TestApp.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
<ItemGroup>
1313
<TrimmerRootAssembly Include="RabbitMQ.Client" />
14-
1514
<TrimmerRootAssembly Update="@(TrimmerRootAssembly)" Path="..\%(Identity)\%(Identity).csproj" />
1615
<ProjectReference Include="@(TrimmerRootAssembly->'%(Path)')" />
1716
</ItemGroup>
1817

19-
</Project>
18+
</Project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
$DebugPreference = "Continue"
2+
$ErrorActionPreference = 'Stop'
3+
# Set-PSDebug -Strict -Trace 1
4+
Set-PSDebug -Off
5+
Set-StrictMode -Version 'Latest' -ErrorAction 'Stop' -Verbose
6+
7+
New-Variable -Name rootDirectory -Option Constant -Value $PSScriptRoot
8+
Write-Host "[INFO] rootDirectory: $rootDirectory"
9+
10+
$runtime = $IsWindows ? "win-x64" : ($IsMacOS ? "macos-x64" : "linux-x64")
11+
$app = $IsWindows ? "./AotCompatibility.TestApp.exe" : "./AotCompatibility.TestApp"
12+
13+
$publishOutput = dotnet publish --runtime=$runtime $rootDirectory/AotCompatibility.TestApp.csproj -nodeReuse:false '/p:UseSharedCompilation=false' '/p:Configuration=Release'
14+
15+
$actualWarningCount = 0
16+
17+
foreach ($line in $($publishOutput -split "`r`n"))
18+
{
19+
if (($line -like "*analysis warning IL*") -or ($line -like "*analysis error IL*"))
20+
{
21+
Write-Host $line
22+
$actualWarningCount += 1
23+
}
24+
}
25+
26+
Write-Host "Actual warning count is:", $actualWarningCount
27+
$expectedWarningCount = 0
28+
29+
if ($LastExitCode -ne 0)
30+
{
31+
Write-Error -ErrorAction Continue -Message "[ERROR] error while publishing AotCompatibility Test App, LastExitCode is $LastExitCode"
32+
Write-Error -ErrorAction Continue -Message $publishOutput
33+
}
34+
35+
Push-Location "$rootDirectory/bin/Release/net6.0/$runtime"
36+
try
37+
{
38+
Write-Host "[INFO] executing: $app"
39+
$app
40+
Write-Host "[INFO] finished executing test app"
41+
42+
if ($LastExitCode -ne 0)
43+
{
44+
Write-Error -ErrorAction Continue -Message "[ERROR] there was an error while executing AotCompatibility Test App. LastExitCode is: $LastExitCode"
45+
}
46+
}
47+
finally
48+
{
49+
Pop-Location
50+
}
51+
52+
$exitCode = 0
53+
if ($actualWarningCount -ne $expectedWarningCount)
54+
{
55+
$exitCode = 1
56+
Write-Error -ErrorAction Continue -Message "Actual warning count: $actualWarningCount is not as expected, which is: $expectedWarningCount"
57+
}
58+
59+
Exit $exitCode

0 commit comments

Comments
 (0)
Please sign in to comment.