-
Notifications
You must be signed in to change notification settings - Fork 259
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
MSTestRunner does not integrate with "VS MSBuild" #4070
Comments
Hi @RuiAlias, I have done some manual checks and the VSTest:
MSTest runner:
I'll mark this as feature request and discuss with the team if we want to support it or not. |
Hi @Evangelink. That error is due to PowerShell syntax. AFAIK PowerShell interprets The "Test" targets exists and works. But it only works if the name of the invoked process is "dotnet.exe". Which is a problem for me because I need to use the "Full MSBuild", that has an executable named "msbuild.exe". From what I've identified the issue has nothing to do with "MSTest.SDK" and is the responsibility of the "Microsoft.Testing.Platform.MSBuild". |
Thanks! Indeed some mistake from me. I have looked at the code and the |
No problem. And thanks for looking into this issue.
MSBuild has a "Test" target since v17.9.5 according to this commit dotnet/msbuild@b9d3539. It's how "Microsoft.Testing.Platform.MSBuild", "Microsoft.Build.RunVSTest" and other test runners are able to integrate with MSBuild. Lines 262 to 268 in 077bf0e
I believe the issue is just this line in "Microsoft.Testing.Platform.MSBuild", that depends on the name of the executable testfx/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs Line 191 in 7eade67
Which basically evaluates to if ("dotnet.exe" != "mono.exe" && "msbuild.exe" == "dotnet.exe") , when running with "Full MSBuild". Now, I'm not sure why this comparison was implemented like this. I assume it was to have a different behavior when running under Mono; and MSBuild was forgotten or not taken into consideration. But it might have been for another reason.
What I do know is that renaming the executable from "msbuild.exe" to "dotnet.exe" is enough to make it work which means that there isn't a deeper issue going on, like that there are missing features in MSBuild, etc.. |
Ooooh I was convinced this code was on dotnet not MSBuild! Changing this ticket as bug then! Thanks for the detailed answers and investigations! |
Describe the bug
An MSTest.Sdk project cannot be tested with "VS MSBuild" (or "Full MSBuild").
Steps To Reproduce
On a Windows machine with "VS MSBuild" and dotnet SDK installed:
You can also see the repro: https://github.com/RuiAlias/mtp-msbuild-repro. On this repro I created a GitHub Actions Workflow that runs the msbuild command and fails: https://github.com/RuiAlias/mtp-msbuild-repro/actions/runs/11858511987/job/33049304509.
Expected behavior
MSBuild.exe
runs the tests successfully.Actual behavior
MSBuild.exe
fails with error:Additional context
I think I've narrowed the problem down to the name of the executable "MSBuild.exe".
testfx/src/Platform/Microsoft.Testing.Platform.MSBuild/Tasks/InvokeTestingPlatformTask.cs
Line 191 in 7eade67
On the repro there is a GitHub Action Workflow that proves this by: renaming the executable from "MSBuild.exe" to "dotnet.exe" and then running
dotnet.exe -restore -t:Build;Test mstest.csproj
, the tests run successfully.dotnet test mstest.csproj
worksdotnet msbuild -restore -t:Build;Test mstest.csproj
worksMSBuild.exe -restore -t:Build;Test mstest.csproj
failsmv MSBuild.exe dotnet.exe; dotnet.exe -restore -t:Build;Test mstest.csproj
workshttps://github.com/RuiAlias/mtp-msbuild-repro/blob/main/.github/workflows/build-and-test.yml
The text was updated successfully, but these errors were encountered: