stryker-mutator / stryker-net

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

When setting the --msbuildPath option, the nuget restore should also use this msbuild to restore all the nuget packages #2356

Closed MischaVreeburg closed 1 year ago

MischaVreeburg commented 1 year ago

I'm trying to use stryker.net to run against a large solution (85 projects) in azure devops pipelines. The projects are sdk style files, but target .NET 4.8 full framework, due to some dependencies. On my local machine, this works fine, where I have vs2019 and vs2022 installed, but in the pipeline the Stryker.NET run fails because it tries to build/restore the projects using VS2017 enterprise msbuild. Both VS2017 Enterprise and VS2019 Enterprise are installed on the build machines. I've tried to supply the msbuild path via the --msbuild-path option, but still this will use the VS2017 enterprise msbuild for the nuget restore.

I'd like to see that the --msbuildpath option is also honored by the nuget restore and thus won't throw or otherwise misbehave when VS2017 Enterprise is installed and a SDK style project targetting .NET48 and using a higher language level than 7.3 is being used, by correctly using the provided msbuild to restore the projects.

As an alternative Stryker.NET should always use the latest version of msbuild, not defaulting to VS2017 Enterprise, as there are currently 2 newer versions of the software out there (2019 and 2022)

Logging from the console illustrating the issue: PS C:\Users\xxxxxxx> dotnet stryker --project "C:\git\xxxxx\Server\Foundation\Common\code\Foundation.Common.csproj" --solution "c:\git\xxxxx\Server\xxxxx.sln" --reporter 'json' --reporter 'progress' --test-project "c:\git\xxxxx\server\Feature\xxxxxxxxxxxxxxxxx\test\xxxxxxxx.xxxxxxxxx.Test\xxxxxxxx.xxxxxxxxx.Test.csproj" --verbosity debug --msbuild-path "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe"

  _____ _              _               _   _ ______ _______
  / ____| |            | |             | \ | |  ____|__   __|
 | (___ | |_ _ __ _   _| | _____ _ __  |  \| | |__     | |
  \___ \| __| '__| | | | |/ / _ \ '__| | . ` |  __|    | |
  ____) | |_| |  | |_| |   <  __/ |    | |\  | |____   | |
 |_____/ \__|_|   \__, |_|\_\___|_| (_)|_| \_|______|  |_|
                   __/ |
                  |___/

[12:04:59 INF] Logging enabled at level Debug Version: 1.5.3 [12:05:01 DBG] Stryker started with options: {"MsBuildPath": "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe", "DevMode": false, "BasePath": "C:\Users\xxxxxxx", "OutputPath": "C:\Users\xxxxxxx\StrykerOutput\2022-12-13.12-04-59", "ReportFileName": "mutation-report", "SolutionPath": "c:\git\xxxxx\Server\xxxxx.sln", "TargetFramework": null, "LogOptions": {"LogToFile": false, "LogLevel": "Debug", "$type": "LogOptions"}, "MutationLevel": "Standard", "Thresholds": {"High": 80, "Low": 60, "Break": 0, "$type": "Thresholds"}, "AdditionalTimeout": 5000, "LanguageVersion": "Default", "Concurrency": 4, "ProjectUnderTestName": "C:\git\xxxxx\Server\Foundation\Common\code\Foundation.Common.csproj", "TestProjects": ["c:\git\xxxxx\server\Feature\xxxxxxxxxxxxxxxxx\test\xxxxxxxx.xxxxxxxxx.Test\xxxxxxxx.xxxxxxxxx.Test.csproj"], "TestCaseFilter": "", "WithBaseline": false, "Reporters": ["Json", "Progress"], "BaselineProvider": "Disk", "AzureFileStorageUrl": "", "AzureFileStorageSas": "", "DashboardUrl": "https://dashboard.stryker-mutator.io/", "DashboardApiKey": null, "Since": false, "SinceTarget": "master", "DiffIgnoreChanges": [], "FallbackVersion": "master", "ModuleName": "", "ReportTypeToOpen": null, "Mutate": [{"Glob": {"Tokens": [{"TrailingPathSeparator": {"Value": "\", "$type": "PathSeparatorToken"}, "LeadingPathSeparator": null, "$type": "WildcardDirectoryToken"}, {"$type": "WildcardToken"}], "$type": "Glob"}, "IsExclude": false, "TextSpans": [{"Start": 0, "End": 2147483647, "Length": 2147483647, "IsEmpty": false, "$type": "TextSpan"}], "$type": "FilePattern"}], "IgnoredMethods": [], "ExcludedMutations": [], "ExcludedLinqExpressions": [], "OptimizationMode": "CoverageBasedTest", "ProjectName": "", "ProjectVersion": "", "$type": "StrykerOptions"} [12:05:01 INF] Identifying project to mutate. [12:05:02 DBG] Using c:\git\xxxxx\server\Feature\xxxxxxxxxxxxxxxxx\test\xxxxxxxx.xxxxxxxxx.Test\xxxxxxxx.xxxxxxxxx.Test.csproj as test project [12:05:02 DBG] Analyzing solution file c:\git\xxxxx\Server\xxxxx.sln A new version of Stryker.NET (3.3.0) is available. Please consider upgrading using dotnet tool update -g dotnet-stryker [12:05:02 DBG] Analyzing project file c:\git\xxxxx\server\Feature\xxxxxxxxxxxxxxxxx\test\xxxxxxxx.xxxxxxxxx.Test\xxxxxxxx.xxxxxxxxx.Test.csproj [12:05:12 DBG] Project analyzer result not successful, restoring packages [12:05:12 INF] Restoring nuget packages using nuget.exe [12:05:12 DBG] Auto detected msbuild version 15.9.21.664 at: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe [12:05:12 DBG] Restoring packages using command: c:\git\nuget61\nuget.exe restore "c:\git\xxxxx\Server\xxxxx.sln" -MsBuildVersion "15.9.21.664"

richardwerkman commented 1 year ago

Fixed by pr