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

MSTest.Sdk project cannot be tested with "VS MSBuild" #4070

Open
RuiAlias opened this issue Nov 15, 2024 · 0 comments
Open

MSTest.Sdk project cannot be tested with "VS MSBuild" #4070

RuiAlias opened this issue Nov 15, 2024 · 0 comments

Comments

@RuiAlias
Copy link

RuiAlias commented Nov 15, 2024

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:

dotnet new mstest
MSBuild.exe -restore -t:Build;Test mstest.csproj

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:

D:\a\mtp-msbuild-repro\mtp-msbuild-repro\bin\Debug\net8.0\mtp-msbuild-repro.dll : error run failed: Tests failed: Possible reasons for this include: [D:\a\mtp-msbuild-repro\mtp-msbuild-repro\mtp-msbuild-repro.csproj]
D:\a\mtp-msbuild-repro\mtp-msbuild-repro\bin\Debug\net8.0\mtp-msbuild-repro.dll : error run failed: Could not execute because the specified command or file was not found. [D:\a\mtp-msbuild-repro\mtp-msbuild-repro\mtp-msbuild-repro.csproj]
D:\a\mtp-msbuild-repro\mtp-msbuild-repro\bin\Debug\net8.0\mtp-msbuild-repro.dll : error run failed:   * You misspelled a built-in dotnet command. [D:\a\mtp-msbuild-repro\mtp-msbuild-repro\mtp-msbuild-repro.csproj]
D:\a\mtp-msbuild-repro\mtp-msbuild-repro\bin\Debug\net8.0\mtp-msbuild-repro.dll : error run failed:   * You intended to execute a .NET program, but dotnet---internal-msbuild-node does not exist. [D:\a\mtp-msbuild-repro\mtp-msbuild-repro\mtp-msbuild-repro.csproj]
D:\a\mtp-msbuild-repro\mtp-msbuild-repro\bin\Debug\net8.0\mtp-msbuild-repro.dll : error run failed:   * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH. [D:\a\mtp-msbuild-repro\mtp-msbuild-repro\mtp-msbuild-repro.csproj]
D:\a\mtp-msbuild-repro\mtp-msbuild-repro\bin\Debug\net8.0\mtp-msbuild-repro.dll : error run failed:  [D:\a\mtp-msbuild-repro\mtp-msbuild-repro\mtp-msbuild-repro.csproj]

Additional context

I think I've narrowed the problem down to the name of the executable "MSBuild.exe".

if (dotnetRunnerName != MonoRunnerName && Path.GetFileName(_currentProcess.MainModule!.FileName!).Equals(dotnetRunnerName, StringComparison.OrdinalIgnoreCase))

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 works
  • dotnet msbuild -restore -t:Build;Test mstest.csproj works
  • MSBuild.exe -restore -t:Build;Test mstest.csproj fails
  • mv MSBuild.exe dotnet.exe; dotnet.exe -restore -t:Build;Test mstest.csproj works

https://github.com/RuiAlias/mtp-msbuild-repro/blob/main/.github/workflows/build-and-test.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant