Skip to content

Commit 3df6f89

Browse files
authored
Fallback to latest runtimeconfig when none is found (#5136)
* Runtime config fallback * Revert playground
1 parent e12f577 commit 3df6f89

File tree

7 files changed

+21
-2
lines changed

7 files changed

+21
-2
lines changed

eng/verify-nupkgs.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ function Verify-Nuget-Packages {
1919
$expectedNumOfFiles = @{
2020
"Microsoft.CodeCoverage" = 59;
2121
"Microsoft.NET.Test.Sdk" = 15;
22-
"Microsoft.TestPlatform" = 607;
22+
"Microsoft.TestPlatform" = 608;
2323
"Microsoft.TestPlatform.Build" = 20;
24-
"Microsoft.TestPlatform.CLI" = 470;
24+
"Microsoft.TestPlatform.CLI" = 471;
2525
"Microsoft.TestPlatform.Extensions.TrxLogger" = 34;
2626
"Microsoft.TestPlatform.ObjectModel" = 92;
2727
"Microsoft.TestPlatform.AdapterUtilities" = 75;

src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo(
415415
// 2) making sure we still make the project executable (and so we actually do get runtimeconfig unless the user tries hard to not make the test and EXE).
416416
var suffix = _targetFramework.Version == "1.0.0.0" ? "latest" : $"{new Version(_targetFramework.Version).Major}.{new Version(_targetFramework.Version).Minor}";
417417
var testhostRuntimeConfig = Path.Combine(Path.GetDirectoryName(testHostNextToRunner)!, $"testhost-{suffix}.runtimeconfig.json");
418+
if (!File.Exists(testhostRuntimeConfig))
419+
{
420+
testhostRuntimeConfig = Path.Combine(Path.GetDirectoryName(testHostNextToRunner)!, $"testhost-latest.runtimeconfig.json");
421+
}
422+
418423
argsToAdd = " --runtimeconfig " + testhostRuntimeConfig.AddDoubleQuote();
419424
args += argsToAdd;
420425
EqtTrace.Verbose("DotnetTestHostmanager: Adding {0} in args", argsToAdd);

src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<file src="$TesthostRuntimeconfig$\testhost-6.0.runtimeconfig.json" target="contentFiles\any\netcoreapp3.1" />
4646
<file src="$TesthostRuntimeconfig$\testhost-7.0.runtimeconfig.json" target="contentFiles\any\netcoreapp3.1" />
4747
<file src="$TesthostRuntimeconfig$\testhost-8.0.runtimeconfig.json" target="contentFiles\any\netcoreapp3.1" />
48+
<file src="$TesthostRuntimeconfig$\testhost-9.0.runtimeconfig.json" target="contentFiles\any\netcoreapp3.1" />
4849
<file src="$TesthostRuntimeconfig$\testhost-latest.runtimeconfig.json" target="contentFiles\any\netcoreapp3.1" />
4950
<file src="netcoreapp3.1\testhost.dll" target="contentFiles\any\netcoreapp3.1" />
5051
<file src="netcoreapp3.1\testhost.deps.json" target="contentFiles\any\netcoreapp3.1" />

src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
<file src="$TesthostRuntimeconfig$\testhost-7.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
7272
<file src="$TesthostRuntimeconfig$\testhost-8.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmPrevious$" />
7373
<file src="$TesthostRuntimeconfig$\testhost-8.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
74+
<file src="$TesthostRuntimeconfig$\testhost-9.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmPrevious$" />
75+
<file src="$TesthostRuntimeconfig$\testhost-9.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
7476
<file src="$TesthostRuntimeconfig$\testhost-latest.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmPrevious$" />
7577
<file src="$TesthostRuntimeconfig$\testhost-latest.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
7678
<file src="$SourceBuildTfmPrevious$\testhost.dll" target="contentFiles\any\$SourceBuildTfmPrevious$" />

src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.sourcebuild.product.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<file src="$TesthostRuntimeconfig$\testhost-6.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
4545
<file src="$TesthostRuntimeconfig$\testhost-7.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
4646
<file src="$TesthostRuntimeconfig$\testhost-8.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
47+
<file src="$TesthostRuntimeconfig$\testhost-9.0.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
4748
<file src="$TesthostRuntimeconfig$\testhost-latest.runtimeconfig.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />
4849
<file src="$SourceBuildTfmCurrent$\testhost.dll" target="contentFiles\any\$SourceBuildTfmCurrent$" />
4950
<file src="$SourceBuildTfmCurrent$\testhost.deps.json" target="contentFiles\any\$SourceBuildTfmCurrent$" />

src/package/Microsoft.TestPlatform/Microsoft.TestPlatform.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@
541541
<file src="$TesthostRuntimeconfig$\testhost-6.0.runtimeconfig.json" target="tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\testhost-6.0.runtimeconfig.json" />
542542
<file src="$TesthostRuntimeconfig$\testhost-7.0.runtimeconfig.json" target="tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\testhost-7.0.runtimeconfig.json" />
543543
<file src="$TesthostRuntimeconfig$\testhost-8.0.runtimeconfig.json" target="tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\testhost-8.0.runtimeconfig.json" />
544+
<file src="$TesthostRuntimeconfig$\testhost-8.0.runtimeconfig.json" target="tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\testhost-9.0.runtimeconfig.json" />
544545
<file src="$TesthostRuntimeconfig$\testhost-latest.runtimeconfig.json" target="tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\testhost-latest.runtimeconfig.json" />
545546
<file src="netcoreapp3.1\testhost.deps.json" target="tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\testhost.deps.json" />
546547
<file src="netcoreapp3.1\testhost.dll" target="tools\net462\Common7\IDE\Extensions\TestPlatform\TestHostNet\testhost.dll" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"runtimeOptions": {
3+
"tfm": "net9.0",
4+
"framework": {
5+
"name": "Microsoft.NETCore.App",
6+
"version": "9.0.0-preview.0"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)