stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.76k stars 175 forks source link

Wrong msbuild version used to build .net framework project #2528

Closed CzBuCHi closed 1 year ago

CzBuCHi commented 1 year ago

Describe the bug Stryker is building project using dotnet build (msbuild for .net core) command even when .net framework project is tested. -> build will fail, because resx are compiled differently in core than in framework.

Expected behavior Build with msbuild command for .net framework project.

Desktop (please complete the following information):

Additional context v 3.8.0 do not have this behavior

dupdob commented 1 year ago

Thanks for reporting that you have an issue. Could you specify which error(s) you have ? And/or could you please provide some logs or a reproduction scenario?

V3.9 indeed includes a massive refactoring of project management logic which could be the source of undetected regressions. That being said, the changes are more complex than switching between msbuild and dotnet build.

I did try the latest version with a simple Net framework project with a resx file and everything went fine.

CzBuCHi commented 1 year ago

im getting this log when running dotnet build in c:\projects\dotnet\Zeus\5.0\ directory: Log.txt

probably useless, but msbuild log loogs like this: msbuild.txt

also i can show you (modified) affected project: Zeus.Windows.Forms.YearGrid.csproj

my guess is that dotnet core changed how Page is compiled ...

edit: my first idea for fix would be to use msbuild if .net framework project is detected instead of dotnet build

rouke-broersma commented 1 year ago

@CzBuCHi that is already what we do, there's just something going wrong in detecting since the solution run rework.

dupdob commented 1 year ago

@CzBuCHi : could you share the command line you are using? I am unable to see any defect in the code. Knowing the selected options would help me narrow my search.

CzBuCHi commented 1 year ago

this is how i run stryker from my command line app:

/// <summary>Runs 'dotnet stryker' command.</summary>
/// <param name="solutionFullPath">Full path to your solution file.</param>
/// <param name="projectName">Used to find the project to test in the project references of the test project.</param>
/// <param name="testProject">Specify the test projects.</param>
/// <param name="extraArgs">Extra arguments for stryker.</param>
public static bool RunStryker([NotNull] string solutionFullPath, [NotNull] string projectName, [NotNull] string testProject, [NotNull] [ItemNotNull] IEnumerable<string> extraArgs) {

// example param values:
// solutionFullPath = @"c:\Path\To\Solution.sln"
// projectName      = "Project.csproj"
// testProject      = @"c:\Path\To\Project.Tests\Project.Tests.csproj"
// extraArgs        = ["-r", "progress"]

    var arguments = new[] {
        "stryker",
        "-s", solutionFullPath,
        "-p", projectName,
        "-tp", testProject,
        "-r", "json",
        "-O", Path.Combine(Directory.GetParent(solutionFullPath).FullName, "StrykerOutput")
    }.Concat(extraArgs);

    var info = new ProcessStartInfo {
        FileName = Dotnet, // = @"C:\Program Files\dotnet\dotnet.exe";
        Arguments = string.Join(" ", arguments),
        WorkingDirectory = Directory.GetParent(testProject).FullName,
        UseShellExecute = false,
    };

    var process = Process.Start(info);
    process.WaitForExit();
    return process.ExitCode == 0;
}
dupdob commented 1 year ago

Thanks. I have tried these options on the net 4.8 integration test projects and Stryker ran as expected, using msbuild to build the project. I am afraid I cannot do much more until you provide us Stryker's own log (using --log-to-file option) or a project reproducing the problem

CzBuCHi commented 1 year ago

ofcourse after pc restart & reinstall of stryker tool i cannot reproduce this error ... so sorry for wastling your time :/