stryker-mutator / stryker-net

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

MSBuild could not be found - issue with NuGet #3067

Open feuerschatten opened 4 days ago

feuerschatten commented 4 days ago

Describe the bug

we´ve updated our stryker vorm V4.06 to V4.3.0 but now I get the following error while mutating a project. We are using .net-framework 4.6.1. so far I can tell msbuild version 15 is installed. Could you please review the error and lead to a solution?

Logs

`2024-10-16T14:09:51.0597257+02:00  [FTL] Failed to restore nuget packages. Nuget error: "Failed to load msbuild Toolset
  Die Datei oder Assembly \"Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
" (5cc89b77)
2024-10-16T14:10:02.4407505+02:00  [DBG] Restoring packages using command: "C:\Users\felix.arnold\AppData\Local\AzureFunctionsTools\Releases\1.13.2\cli_x64\NuGet.exe" "restore \"C:\source\repos\tfs\Something\11 Source code\Trunk\C#\C3000\C3000.sln\" -MsBuildVersion \"17.7.2.37605\"" (649441ac)
2024-10-16T14:10:02.4413006+02:00  [DBG] Restoring packages using command: "C:\Users\felix.arnold\AppData\Local\AzureFunctionsTools\Releases\1.13.2\cli_x64\NuGet.exe" "restore \"C:\source\repos\tfs\Something\11 Source code\Trunk\C#\C3000\C3000.sln\" -MsBuildVersion \"17.7.2.37605\"" (649441ac)
2024-10-16T14:10:02.7042795+02:00  [FTL] Failed to restore nuget packages. Nuget error: "Failed to load msbuild Toolset
  Die Datei oder Assembly \"Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
" (5cc89b77)
2024-10-16T14:10:02.7165744+02:00  [FTL] Failed to restore nuget packages. Nuget error: "Failed to load msbuild Toolset
  Die Datei oder Assembly \"Microsoft.Build, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
" (5cc89b77)
2024-10-16T14:10:02.7175197+02:00  [INF] Analysis complete. (f039f576)
2024-10-16T14:10:02.7349404+02:00  [ERR] An error occurred during the mutation test run  (2ecaed66)
System.AggregateException: One or more errors occurred. (Nuget.exe failed to restore packages for your solution. Please review your nuget setup.) (Nuget.exe failed to restore packages for your solution. Please review your nuget setup.) (Nuget.exe failed to restore packages for your solution. Please review your nuget setup.)
 ---> 
Nuget.exe failed to restore packages for your solution. Please review your nuget setup.
WARNUNG: Failed to load C:\Users\felix.arnold\AppData\Local\AzureFunctionsTools\Releases\1.13.2\cli_x64\Microsoft.Azure.WebJobs.Extensions.dll
Die Datei oder Assembly "Microsoft.Azure.WebJobs.Host, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)
   --- End of inner exception stack trace ---
   at Stryker.Core.Initialisation.InputFileResolver.AnalyzeAllNeededProjects(List`1 projectList, StrykerOptions options, IAnalyzerManager manager, ScanMode mode) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs:line 174
   at Stryker.Core.Initialisation.InputFileResolver.AnalyzeAndIdentifyProjects(List`1 projectList, StrykerOptions options, IAnalyzerManager manager, ScanMode mode) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs:line 124
   at Stryker.Core.Initialisation.InputFileResolver.ResolveSourceProjectInfos(StrykerOptions options) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs:line 66
   at Stryker.Core.Initialisation.InitialisationProcess.GetMutableProjectsInfo(StrykerOptions options) in /_/src/Stryker.Core/Stryker.Core/Initialisation/InitialisationProcess.cs:line 57
   at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(StrykerOptions options, IReporter reporters, ITestRunner runner) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 52
   at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs, ILoggerFactory loggerFactory, IProjectOrchestrator projectOrchestrator) in /_/src/Stryker.Core/Stryker.Core/StrykerRunner.cs:line 63
   at Stryker.CLI.StrykerCli.RunStryker(IStrykerInputs inputs) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 151
   at Stryker.CLI.StrykerCli.<>c__DisplayClass11_0.<Run>b__0() in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 123
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
 ---> (Inner Exception #1) 
Nuget.exe failed to restore packages for your solution. Please review your nuget setup.
WARNUNG: Failed to load C:\Users\felix.arnold\AppData\Local\AzureFunctionsTools\Releases\1.13.2\cli_x64\Microsoft.Azure.WebJobs.Extensions.dll
Die Datei oder Assembly "Microsoft.Azure.WebJobs.Host, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)
<---
 ---> (Inner Exception #2) 
Nuget.exe failed to restore packages for your solution. Please review your nuget setup.
WARNUNG: Failed to load C:\Users\felix.arnold\AppData\Local\AzureFunctionsTools\Releases\1.13.2\cli_x64\Microsoft.Azure.WebJobs.Extensions.dll
Die Datei oder Assembly "Microsoft.Azure.WebJobs.Host, Version=2.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)`

Expected behavior The new version should work like the previouse.

Desktop (please complete the following information):

dupdob commented 3 days ago

What happened

A project analysis failed, and as it was a Net framework project, Stryker tried a Nuget restore before another attempt. Which repeatedly failed (3 times), leading to an early termination from Stryker.

What is the immediate cause of this issue

The nuget restore operation should have succeeded. It failed either because Stryker (1) failed to set it up properly or (2), because nuget installation is somehow corrupted.

Why did it not happen in earlier version (V4.06-)

Successful logs (shared via Stryker's slack) showed that earlier Stryker versions made no nuget restore attempts. Stryker V4.1 introduced an improved project analysis logic which increased the overall reliability of projects analysis. One of the changes is that Stryker do a nuget restore when an analysis failed. Since there have been no significant change in how this is requested (by Stryker), one can assume earlier Stryker version would face the same error when trying a nuget restore.

What are the issues

  1. There is probably a problem in how Stryker tries to run nuget restore which does not properly handle situation where several SDK's are installed.
  2. There may be a problem with project analysis: there is no clear reason why it may have failed. Running Stryker with --dev-mode option would provide a detailed log of the failure

What can be done

1) in the short term, there is no clear workaround. The best way to address this locally would be to see why project analysis failed (via --dev-mode option) and try to fix it. 2) nuget discovery and use logic needs to be improved and secured