Skip to content

Commit

Permalink
Fix net48 tests in VS 2022 to not use AppDomain
Browse files Browse the repository at this point in the history
A custom .runsettings file is required for this with MSTest 3.
  • Loading branch information
menees committed May 25, 2024
1 parent 7475eda commit 461e4fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<NoWarn>1701;1702;1705;SA0001;SA1413</NoWarn>
<AssemblyOriginatorKeyFile/>
<CodeAnalysisRuleSet>..\..\src\Analyzers.ruleset</CodeAnalysisRuleSet>
<RunSettingsFilePath>$(MSBuildThisFileDirectory)Directory.runsettings</RunSettingsFilePath>

<!--We can't use MSTest Runner until our build.ps1 is updated to use the .exe outputs.
https://devblogs.microsoft.com/dotnet/introducing-ms-test-runner/ -->
Expand Down
16 changes: 16 additions & 0 deletions tests/Directory.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<!-- https://superuser.com/a/1376408/430448 -->
<!-- https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019#elements-of-a-runsettings-file -->
<ResultsDirectory>..\TestResults</ResultsDirectory>
<TargetPlatform>x64</TargetPlatform>
<!-- https://github.com/microsoft/vstest-docs/blob/main/docs/configure.md -->
<!-- Also, required for MSTest 3 on .NET Framework. https://github.com/microsoft/testfx/issues/1437 -->
<DisableAppDomain>true</DisableAppDomain>
</RunConfiguration>

<MSTest>
<DeploymentEnabled>False</DeploymentEnabled>
</MSTest>
</RunSettings>
1 change: 1 addition & 0 deletions tests/Menees.Analyzers.Test/Menees.Analyzers.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<None Include="..\Directory.Build.props" Link="Directory.Build.props" />
<None Include="..\Directory.runsettings" Link="Directory.runsettings" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 461e4fe

Please sign in to comment.