Skip to content

Stryker should use Msbuild instead of dotnet build when msbuild path is specified #3182

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

Open
MichalMucek opened this issue Feb 5, 2025 · 5 comments
Labels
🚀 Feature request New feature or request

Comments

@MichalMucek
Copy link

Given a scenario where:

  • Stryker is executed on a single test project and single target project,
  • msbuild-path is defined.

When an initial build fails using the dotnet build command - whether for a test project or a target project - it does not fall back to the specified MSBuild, as it does when Stryker is executed at the solution level.

Logs

For simplicity, the attached logs show an example of a syntax error, only to point out that the fallback to MSBuild would try to work. IRL, the Windows App SDK projects can't be built with .NET SDK (I guess there are some dependencies to .NET Framework in the build process) and still rely on MSBuild and its workloads.

Logs - Project level, failure without fallback to MSBuild.txt
Logs - Solution level, failure with fallback to MSBuild.txt

Expected behavior
The fallback to MSBuild works for the project level just as for the solution.

Ideal behavior
When msbuild-path is defined, dotnet build should be omitted.

  • OS: Windows 11
  • Type of project: Windows App SDK
  • Framework Version: .NET 8.0
  • Stryker Version: 5.4.1
@MichalMucek MichalMucek added the 🐛 Bug Something isn't working label Feb 5, 2025
@dupdob
Copy link
Member

dupdob commented Feb 6, 2025

hi, thanks for the opening the issue.
This sounds like a good idea, but as the sample you provide fails to build in both cases, what problem are you trying to solve ?

@MichalMucek
Copy link
Author

@dupdob Stryker is trying to build a project that targets net8.0-windows10.0.19041.0 (Windows App SDK). Since the dotnet build of .NET SDK fails for our Windows App SDK project, we must rely on Visual Studio (MSBuild) with appropriate workloads. When running Stryker on a project, dotnet build fails (as expected by us) and doesn't fall back to the specified MSBuild. Therefore, we're unable to run Stryker on a single test project.

By providing the logs, I meant to focus on the fallback mechanism. Not the errors themselves. Let's assume that for the solution, dotnet build fails, and then the building succeeds when MSBuild is used.

@dupdob
Copy link
Member

dupdob commented Feb 6, 2025

Thanks for the precision. For information, our experience is that one needs to provide the solution file for such project to be built. Stryker raises an error for this kind of situation, but it relies on the framework version for identification.
I will try and reproduce the issue to see what is the actual situation with net 8 windows

@dupdob dupdob added 🚀 Feature request New feature or request and removed 🐛 Bug Something isn't working labels Feb 6, 2025
@dupdob
Copy link
Member

dupdob commented Feb 6, 2025

Some clarifications:
Stryker reverts to MsBuild only when a solution file is present because MsBuild may be the only solution to restore package for some old project (via the solution file). As such, Stryker calls MsBuild twice: once for restore and one for build.
Dotnet build failed, trying with MsBuild and forcing package restore.

We do that for a specific known situation. I do not think it is a good idea to generalize this, because:

  1. if the build fails for some valid reason (such the syntax error of your sample), we want to stop it as soon as possible
  2. if a project requires MsBuild to build properly, it would be a waste of time to try using dotnet buil every time.

But, it definitely makes sense to favor msbuild if a specific path is provided.

@dupdob dupdob changed the title Stryker doesn't fall back to pointed MSBuild when performing on a single project Stryker should use Msbuild instead of dotnet build when msbuild path is specified Feb 6, 2025
@MichalMucek
Copy link
Author

Would this (now a) feature apply to both levels - solution and project? It would be good if it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants