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

TargetFramework cannot be set in Directory.Build.props #3144

Open
Liversage opened this issue Dec 19, 2024 · 2 comments
Open

TargetFramework cannot be set in Directory.Build.props #3144

Liversage opened this issue Dec 19, 2024 · 2 comments
Labels
🐛 Bug Something isn't working

Comments

@Liversage
Copy link

Describe the bug

When <TargetFramework> is set in Directory.Build.props Stryker doesn't work.

Logs

I have a a solution folder with a Directory.Build.props that specifies <TargetFramework>net9.0</TargetFramework> and there are no <TargetFramework> in the .csproj files. The project to mutate and the unit test project are in subdirectories and the unit test project has a reference to the project to mutate. When executing dotnet stryker --verbosity debug in the unit test project I get the following console output:

[13:07:16 INF] Logging enabled at level Debug
Version: 4.4.1
[13:07:16 DBG] Stryker starting, version: 4.4.1

[13:07:16 DBG] Stryker started with options: [REMOVED FOR BREVITY]
[13:07:16 INF] Analysis starting.
[13:07:16 DBG] Using C:\Users\[REDACTED]\[REDACTED].UnitTests\[REDACTED].UnitTests.csproj as test project
[13:07:16 INF] Analyzing 1 test project(s).
[13:07:16 DBG] Analyzing 0 projects.
[13:07:16 DBG] Analyzing [REDACTED].UnitTests.csproj
[13:07:22 DBG] Analysis of project [REDACTED].UnitTests.csproj succeeded.
[13:07:23 DBG] Analyzing ..\[REDACTED]\[REDACTED].csproj
[13:07:29 DBG] Analysis of project ..\[REDACTED]\[REDACTED].csproj succeeded.
[13:07:29 INF] Analysis complete.
[13:07:29 INF] Time Elapsed 00:00:13.2623456
Stryker.NET failed to mutate your project. For more information see the logs below:


No project references found. Please add a project reference to your test project and retry.

Expected behavior

According to the logs Stryker correctly detects the project to mutate and should go ahead and perform the tests.

Adding <TargetFramework>net9.0</TargetFramework> to both .csproj files fixes the problem.

Desktop

  • OS: Windows
  • Type of project: "core"
  • Framework Version: .NET 9.0
  • Stryker Version: 4.4.1

Additional context

I haven't tried to locate the actual problem in the source code. Even if it's not worth fixing it might be helpful to explain this in the documentation. This is my first time using Stryker and it took me quite some time to understand why my project didn't work with Stryker despite following the clear and useful instructions in "Getting started".

@Liversage Liversage added the 🐛 Bug Something isn't working label Dec 19, 2024
@dupdob
Copy link
Member

dupdob commented Dec 19, 2024

Thanks for raising this issue. We will look into it.
We may need more information if we fail to reproduce the problem.

Note that the issue may likely be within the Buildalyzer package Stryker uses for project analysis.

See phmonte/Buildalyzer#166

@Liversage
Copy link
Author

@dupdob Yes, that's exactly the issue. The <TargetFramework> is not being picked up correctly so probably not something that can be fixed by this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants