Skip to content

Commit

Permalink
Adding Process Query Flag For UWP .NET 9 Support (#15003)
Browse files Browse the repository at this point in the history
* adding flag for circumventing process query when running uwp

* update testhost target condition


Co-authored-by: Adam Stephenson <[email protected]>
  • Loading branch information
adstep and adam-stephenson authored Feb 6, 2025
1 parent 1105ca7 commit a815dc0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ extends:
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/VSSetup/Release'
ArtifactName: VSSetupArtifacts

- ${{ each pool in parameters.otherOsPools }}:
- job: ${{ pool.os }}
dependsOn: Windows
Expand Down Expand Up @@ -250,7 +250,7 @@ extends:
condition: failed()

- job: Publish
dependsOn:
dependsOn:
- ${{ each pool in parameters.otherOsPools }}:
- ${{ pool.os }}
pool:
Expand Down
14 changes: 7 additions & 7 deletions eng/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Verify-Nuget-Packages {
"Microsoft.TestPlatform.ObjectModel" = 92;
"Microsoft.TestPlatform.AdapterUtilities" = 61;
"Microsoft.TestPlatform.Portable" = 608;
"Microsoft.TestPlatform.TestHost" = 62;
"Microsoft.TestPlatform.TestHost" = 63;
"Microsoft.TestPlatform.TranslationLayer" = 122;
"Microsoft.TestPlatform.Internal.Uwp" = 38;
}
Expand Down Expand Up @@ -189,8 +189,8 @@ function Verify-NugetPackageExe {
}

$errs = @()
$exes = $UnzipNugetPackages | Get-ChildItem -Filter *.exe -Recurse -Force
if (0 -eq @($exes).Length) {
$exes = $UnzipNugetPackages | Get-ChildItem -Filter *.exe -Recurse -Force
if (0 -eq @($exes).Length) {
throw "No exe files were found."
}

Expand All @@ -215,7 +215,7 @@ function Verify-NugetPackageExe {
$fullName = $_.FullName
$name = $_.Name

if ("x86" -eq $platform) {
if ("x86" -eq $platform) {
$corFlagsOutput = & $corFlags $fullName
# this is an native x86 exe or a .net x86 that requires of prefers 32bit
$platform = if ($corFlagsOutput -like "*does not have a valid managed header*" -or $corFlagsOutput -like "*32BITREQ : 1*" -or $corFlagsOutput -like "*32BITPREF : 1*") {
Expand Down Expand Up @@ -268,7 +268,7 @@ function Verify-NugetPackageExe {
"Success: $name is $platform - $fullName"
}

if ($errs) {
if ($errs) {
throw "Fail!:`n$($errs -join "`n")"
}
}
Expand All @@ -282,7 +282,7 @@ function Verify-NugetPackageVersion {
)

# look for vstest.console.dll because unified build for .NET does not produce vstest.console.exe
$exes = $UnzipNugetPackages | Get-ChildItem -Filter vstest.console.dll -Recurse -Force
$exes = $UnzipNugetPackages | Get-ChildItem -Filter vstest.console.dll -Recurse -Force
if (0 -eq @($exes).Length) {
throw "No vstest.console.dll files were found."
}
Expand All @@ -294,7 +294,7 @@ function Verify-NugetPackageVersion {
else {
"$_ version $($_.VersionInfo.ProductVersion) is ok."
}
}
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,8 @@
<None Update="Microsoft.TestPlatform.TestHost.props" Condition=" $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppMinimum)')) ">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Microsoft.TestPlatform.TestHost.targets" Condition=" $([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', '$(NetCoreAppMinimum)')) ">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<file src="net8.0\testhost.x86.exe" target="build\net8.0\x86\" />

<file src="net8.0\Microsoft.TestPlatform.TestHost.props" target="build\net8.0\" />
<file src="net8.0\Microsoft.TestPlatform.TestHost.targets" target="build\net8.0\" />


<!-- Add localized resources net8.0 -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_MSTestEnableParentProcessQuery Condition="'$(UseUwpTools)'=='true'">false</_MSTestEnableParentProcessQuery>
<_MSTestEnableParentProcessQuery Condition="'$(_MSTestEnableParentProcessQuery)'==''">true</_MSTestEnableParentProcessQuery>
</PropertyGroup>
<ItemGroup>
<RuntimeHostConfigurationOption
Include="MSTest.EnableParentProcessQuery"
Value="$(_MSTestEnableParentProcessQuery)"
Trim="true" />
</ItemGroup>
</Project>
12 changes: 12 additions & 0 deletions src/testhost.x86/DefaultEngineInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ internal class DefaultEngineInvoker :

private const string RemotePath = "--remote-path";

private static readonly bool EnableParentProcessQuery =
AppContext.TryGetSwitch(
switchName: "MSTest.EnableParentProcessQuery",
isEnabled: out bool value)
? value : true;

private readonly ITestRequestHandler _requestHandler;

private readonly IDataCollectionTestCaseEventSender _dataCollectionTestCaseEventSender;
Expand Down Expand Up @@ -213,6 +219,12 @@ private void SetParentProcessExitCallback(IDictionary<string, string?> argsDicti
throw new ArgumentException($"Argument {ParentProcessIdArgument} was not specified.");
}

if (!EnableParentProcessQuery)
{
EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: Skipping querying parent process with id: '{0}'", parentProcessId);
return;
}

EqtTrace.Info("DefaultEngineInvoker.SetParentProcessExitCallback: Monitoring parent process with id: '{0}'", parentProcessId);

if (parentProcessId == -1)
Expand Down

0 comments on commit a815dc0

Please sign in to comment.