Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InvokeTestingPlatformTask to handle running with msbuild.exe and 'Test' target #4840

Merged
merged 10 commits into from
Feb 4, 2025

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jan 30, 2025

Fixes #4070

@Youssef1313 Youssef1313 marked this pull request as ready for review January 31, 2025 09:38
Evangelink
Evangelink previously approved these changes Jan 31, 2025
@Evangelink
Copy link
Member

@Youssef1313 don't forget to link the ticket

@Youssef1313
Copy link
Member Author

2025-01-31T12:10:37.0321498Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: The specified task executable "dotnet.exe" could not be run. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.0416885Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) The specified task executable "dotnet.exe" could not be run. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.0437432Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: File name: 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.0547738Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) File name: 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.0587726Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: at Microsoft.Testing.Platform.MSBuild.Tasks.DotnetMuxerLocator.GetMuxerFromGlobalRegistrationWin(PlatformArchitecture targetArchitecture) [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.0619621Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) at Microsoft.Testing.Platform.MSBuild.Tasks.DotnetMuxerLocator.GetMuxerFromGlobalRegistrationWin(PlatformArchitecture targetArchitecture) [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.0629522Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: at Microsoft.Testing.Platform.MSBuild.Tasks.DotnetMuxerLocator.TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, String& muxerPath) in /_/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/DotnetMuxerLocator.cs:line 130 [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.0658380Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) at Microsoft.Testing.Platform.MSBuild.Tasks.DotnetMuxerLocator.TryGetDotnetPathByArchitecture(PlatformArchitecture targetArchitecture, String& muxerPath) in /_/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/DotnetMuxerLocator.cs:line 130 [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.0715440Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: at Microsoft.Testing.Platform.MSBuild.InvokeTestingPlatformTask.GenerateFullPathToTool() in /_/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs:line 130 [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.0793294Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) at Microsoft.Testing.Platform.MSBuild.InvokeTestingPlatformTask.GenerateFullPathToTool() in /_/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs:line 130 [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.0813840Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.ComputePathToTool() [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.0840433Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) at Microsoft.Build.Utilities.ToolTask.ComputePathToTool() [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.0933834Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.1038775Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) at Microsoft.Build.Utilities.ToolTask.Execute() [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.1051025Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.1057721Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.1073737Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: WRN: Assembly binding logging is turned OFF. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.1079125Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) WRN: Assembly binding logging is turned OFF. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.1119976Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.1272086Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.1305788Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: Note: There is some performance penalty associated with assembly bind failure logging. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.1445161Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) Note: There is some performance penalty associated with assembly bind failure logging. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.1516972Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.1565933Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.1601280Z D:\a\_work\1\s\.packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj] [D:\a\_work\1\s\test\IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests\Microsoft.Testing.Platform.Acceptance.IntegrationTests.csproj]
2025-01-31T12:10:37.1639377Z ##[error].packages\microsoft.testing.platform.msbuild\1.6.0-ci\buildMultiTargeting\Microsoft.Testing.Platform.MSBuild.targets(322,5): error MSB6003: (NETCORE_ENGINEERING_TELEMETRY=Build) [D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj]
2025-01-31T12:10:37.1747431Z     Done Building Project "D:\a\_work\1\s\artifacts\tmp\Debug\testsuite\d2xJk\MSBuildTests\MSBuild Tests.csproj" (Build;Test target(s)) -- FAILED.
2025-01-31T12:10:37.1821410Z     Build FAILED.

For some reason, I cannot repro this locally.

I found this very old issue which looks somewhat related dotnet/sdk#8124. The integration test is running MSBuild.exe on some project, and we have a custom ToolTask that will attempt to run dotnet.exe. Is there something obvious for you? @rainersigwald

@rainersigwald
Copy link
Member

Any hope of getting a binlog? I wonder if something is setting DOTNET_HOST_PATH or something?

@Youssef1313
Copy link
Member Author

msbuild.zip

Nope, DOTNET_HOST_PATH doesn't seem to be set

@Youssef1313
Copy link
Member Author

@rainersigwald Note: Microsoft.Testing.Platform.MSBuild project has a dependency on Microsoft.Win32.Registry NuGet package because we try to read registry key when resolving for dotnet.exe on Windows. I assume our packaging here for the MSBuild task is incorrect and we should ship dlls of dependencies (such as Microsoft.Win32.Registry) in _MSBuildTasks folder of the package (this is the folder that we use the task from in UsingTask)

@@ -47,6 +47,7 @@ This package provides MSBuild integration of the platform, its extensions and co
<ItemGroup>
<TfmSpecificPackageFile Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('PrivateAssets', 'All'))" PackagePath="lib\$(TargetFramework)\%(ReferenceCopyLocalPaths.DestinationSubDirectory)" />
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('CopyToBuildOutput', 'true'))" TargetPath="%(ReferenceCopyLocalPaths.DestinationSubDirectory)" />
<BuildOutputInPackage Include="@(RuntimeTargetsCopyLocalItems->HasMetadata('NuGetPackageId'))" TargetPath="%(RuntimeCopyLocalPaths.DestinationSubPath)" />
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully this gets us green.

It adds three extra dlls to the package:

image

@rainersigwald Is this the right way to package?

Evangelink
Evangelink previously approved these changes Feb 4, 2025
@Evangelink Evangelink enabled auto-merge (squash) February 4, 2025 11:36
@Evangelink Evangelink merged commit e6974d5 into microsoft:main Feb 4, 2025
8 checks passed
@Youssef1313 Youssef1313 deleted the msbuild-fix branch February 4, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MSTestRunner does not integrate with "VS MSBuild"
3 participants