Skip to content

Add support for MSBuild 18 and VS2026 #4658

@peymanr34

Description

@peymanr34

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

6.0.0

Operating system

Windows

Operating system architecture

x64

CI Server

No response

What are you seeing?

If only Visual Studio 2026 is installed on the machine, Cake.Tool will fallback to the old MSBuild located in: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe since MSBuild 18 it's not currently supported.

What is expected?

It should use the MSBuild 18 located in: C:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\amd64\MSBuild.exe

Steps to Reproduce

  1. Make sure you have only Visual Studio 2026 installed.
  2. Run the following task:
var configuration = Argument("configuration", "Release");

Task("Restore")
    .Does(() =>
{
    MSBuild("./Source/Project.sln", new MSBuildSettings
    {
        Target = "Restore",
        Verbosity = Verbosity.Minimal,
        Configuration = configuration,
    });
});

Output log

Executing task: Restore
Executing: "C:/Windows/Microsoft.NET/Framework64/v4.0.30319/MSBuild.exe" /v:minimal /p:Configuration="Release" /target:Restore "F:/<omitted>/Source/Project.sln"
Microsoft (R) Build Engine version 4.8.9221.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved
F:\<omitted>\Source\Project.sln.metaproj : error
MSB4057: The target "Restore" does not exist in the project. [F:\<omitted>\Source\Project.sln]
An error occurred when executing task 'Restore'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions