Skip to content

Could not find a suitable MSBuild instance - VS 2026 #1566

@douglaseccker

Description

@douglaseccker

Usage Information

9.0.4

Description

After uninstalling Visual Studio 2022 and installing Visual Studio 2026, NUKE can no longer locate a valid MSBuild instance. This appears to be the same underlying problem as issue #820, but triggered by the newer VS 2026 installation.

Reproduction Steps

Create a Nuke target definition using the MsBuild task.

Target CompileMsBuild => _ => _
      .Executes(() =>
      {
         MSBuild(s => s
            .SetTargetPath(Solution)
         );
      });

run the target:

dotnet nuke CompileMsBuild

Expected Behavior

I expect the resolver to find the path to MSBuild in its default path "C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Current\Bin\MSBuild.exe"

or for the Insiders version "C:\Program Files\Microsoft Visual Studio\18\Insiders\MSBuild\Current\Bin\MSBuild.exe"

Actual Behavior

╬═══════════════════
║ CompileMsBuild
╬══════════
 ​
17:14:13 [ERR] Target CompileMsBuild has thrown an exception
System.ArgumentException: Could not find a suitable MSBuild instance.
   at Nuke.Common.Assert.NotNull[T](T obj, String message, String argumentExpression) in /_/source/Nuke.Utilities/Assert.cs:line 73
   at Nuke.Common.Tools.MSBuild.MSBuildToolPathResolver.Resolve(Nullable`1 msBuildVersion, Nullable`1 msBuildPlatform) in /_/source/Nuke.Common/Tools/MSBuild/MSBuildToolPathResolver.cs:line 21
   at Nuke.Common.Tools.MSBuild.MSBuildTasks.GetToolPath(ToolOptions options) in /_/source/Nuke.Common/Tools/MSBuild/MSBuildTasks.cs:line 32
   at Nuke.Common.Tooling.ToolTasks.GetToolPathInternal(ToolOptions options) in /_/source/Nuke.Tooling/ToolTasks.ToolPath.cs:line 30
   at Nuke.Common.Tooling.ToolTasks.Run[T](T options) in /_/source/Nuke.Tooling/ToolTasks.Run.cs:line 24
   at Nuke.Common.Tools.MSBuild.MSBuildTasks.MSBuild(Configure`1 configurator) in /_/source/Nuke.Common/Tools/MSBuild/MSBuild.Generated.cs:line 32
   at XXXXX.Nuke.Build.<get_CompileMsBuild>b__16_1() in C:\test\nuke\Build.cs:line 70
   at Nuke.Common.Execution.BuildExecutor.<>c.<Execute>b__4_2(Action x) in /_/source/Nuke.Build/Execution/BuildExecutor.cs:line 120
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Nuke.Common.Execution.BuildExecutor.Execute(NukeBuild build, ExecutableTarget target, IReadOnlyCollection`1 previouslyExecutedTargets, Boolean failureMode) in /_/source/Nuke.Build/Execution/BuildExecutor.cs:line 120

Regression?

No response

Known Workarounds

No response

Could you help with a pull-request?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions