Skip to content

Cake Frosting build of project using MSBuild.SDK.SystemWeb fails when using VS2026 environment #4654

@mdavis

Description

@mdavis

Prerequisites

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

Cake runner

Cake Frosting

Cake version

6.0.0

Operating system

Windows

Operating system architecture

x64

CI Server

No response

What are you seeing?

A Cake Frosting build project fails to build a project using the MSBuild.SDK.SystemWeb SDK (for converting old ASP.NET projects on the .NET Framework to SDK-style projects) if the environment is configured for VS2026, but succeeds if it is configured for VS2022.

The error message contains the following:

C:\Users\...\.nuget\packages\msbuild.sdk.systemweb\4.0.106\Sdk\Sdk.targets(32,3): error MSB4019: The imported project
"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v18.0\WebApplications\Micros
oft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "$(WebApplicationsTarg
etPath)", which evaluated to "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio
\v18.0\WebApplications\Microsoft.WebApplication.targets", is correct, and that the file exists on disk. [D:\git\VS2026W
ebApp\VS2026WebApp\VS2026WebApp.csproj]

The value of the WebApplicationsTargetPath variable appears to have been generated incorrectly; the start of it is getting a VS2022 folder, but the end of it has "v18.0" (i.e., VS2026). It looks like Cake is still getting the VS2022 version of MSBuild, and it's generating first part of that path, but the "18.0" is being pulled from the VisualStudioVersion environment variable. (Also, be aware that the actual folder for VS2026 is not "C:\Program Files\Microsoft Visual Studio\2026" but "C:\Program Files\Microsoft Visual Studio\18".)

What is expected?

The build should succeed regardless of whether a VS2022 or VS2026 environment is configured.

Steps to Reproduce

  1. On a machine with VS2022 and VS2026 installed, unzip this to a folder: VS2026WebApp.zip
  2. Run the included build-vs2026.ps1 PowerShell script to configure the environment for VS2026 and run the Cake Frosting build. It should fail with an error like the one described above. It may help to use a clean PowerShell instance (i.e., pwsh -noprofile)
  3. In a new PowerShell instance, run the included build-vs2022.ps1 PowerShell script to configure the environment for VS2022 and run the Cake Frosting build. It should succeed.

Output log

PS D:\git\VS2026WebApp> .\build-vs2026.ps1 --verbosity=diagnostic
**********************************************************************
** Visual Studio 2026 Developer PowerShell v18.0.0
** Copyright (c) 2025 Microsoft Corporation
**********************************************************************
NuGet Config not specified. Will use NuGet default mechanism for resolving it.
Registering task: Build
Registering task: Default

========================================
Build
========================================
Executing task: Build
Executing: "C:/Program Files/Microsoft Visual Studio/2022/Professional/MSBuild/Current/Bin/amd64/MSBuild.exe" /v:normal /p:Configuration="Release" /target:Build "D:/git/VS2026WebApp/VS2026WebApp.slnx"
MSBuild version 17.14.23+b0019275e for .NET Framework
Build started 11/11/2025 9:27:20 PM.

Project "D:\git\VS2026WebApp\VS2026WebApp.slnx" on node 1 (Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Release|Any CPU".
Project "D:\git\VS2026WebApp\VS2026WebApp.slnx" (1) is building "D:\git\VS2026WebApp\VS2026WebApp\VS2026WebApp.csproj"
(2) on node 1 (default targets).
C:\Users\...\.nuget\packages\msbuild.sdk.systemweb\4.0.106\Sdk\Sdk.targets(32,3): error MSB4019: The imported project
"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v18.0\WebApplications\Micros
oft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "$(WebApplicationsTarg
etPath)", which evaluated to "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio
\v18.0\WebApplications\Microsoft.WebApplication.targets", is correct, and that the file exists on disk. [D:\git\VS2026W
ebApp\VS2026WebApp\VS2026WebApp.csproj]
Done Building Project "D:\git\VS2026WebApp\VS2026WebApp\VS2026WebApp.csproj" (default targets) -- FAILED.

Done Building Project "D:\git\VS2026WebApp\VS2026WebApp.slnx" (Build target(s)) -- FAILED.


Build FAILED.

"D:\git\VS2026WebApp\VS2026WebApp.slnx" (Build target) (1) ->
"D:\git\VS2026WebApp\VS2026WebApp\VS2026WebApp.csproj" (default target) (2) ->
  C:\Users\...\.nuget\packages\msbuild.sdk.systemweb\4.0.106\Sdk\Sdk.targets(32,3): error MSB4019: The imported projec
t "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStudio\v18.0\WebApplications\Micr
osoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "$(WebApplicationsTa
rgetPath)", which evaluated to "C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VisualStud
io\v18.0\WebApplications\Microsoft.WebApplication.targets", is correct, and that the file exists on disk. [D:\git\VS202
6WebApp\VS2026WebApp\VS2026WebApp.csproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.22
An error occurred when executing task 'Build'.
Completed in 00:00:00.3198215

Task                          Duration            Status
----------------------------------------------------------------------
Build                         00:00:00.3206567    Failed
----------------------------------------------------------------------
Total:                        00:00:00.3206567
Error: Cake.Core.CakeReportException: MSBuild: Process returned an error (exit code 1).
 ---> Cake.Core.CakeException: MSBuild: Process returned an error (exit code 1).
   at Cake.Core.Tooling.Tool`1.ProcessExitCode(Int32 exitCode)
   at Cake.Core.Tooling.Tool`1.Run(TSettings settings, ProcessArgumentBuilder arguments, ProcessSettings processSettings, Action`1 postAction)
   at Cake.Common.Tools.MSBuild.MSBuildRunner.Run(FilePath solution, MSBuildSettings settings, Action`1 standardOutputAction)
   at Cake.Common.Tools.MSBuild.MSBuildAliases.MSBuild(ICakeContext context, FilePath solution, MSBuildSettings settings)
   at Build.BuildTask.Run(BuildContext context) in D:\git\VS2026WebApp\build\BuildTask.cs:line 11
   at Cake.Frosting.FrostingTask`1.Cake.Frosting.IFrostingTask.RunAsync(ICakeContext context)
   at Cake.Core.CakeTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.ExecuteAsync(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.ExecuteTaskAsync(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.RunTask(ICakeContext context, IExecutionStrategy strategy, CakeTask task, String target, Stopwatch stopWatch, CakeReport report)
   at Cake.Core.CakeEngine.RunTarget(ICakeContext context, IExecutionStrategy strategy, CakeTask[] orderedTasks, String target, Boolean exclusive, Stopwatch stopWatch, CakeReport report)
   at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, ExecutionSettings settings)
   --- End of inner exception stack trace ---
   at Cake.Core.CakeEngine.RunTargetAsync(ICakeContext context, IExecutionStrategy strategy, ExecutionSettings settings)
   at Cake.Cli.BuildScriptHost`1.internalRunTargetAsync()
   at Cake.Cli.BuildScriptHost`1.RunTargetsAsync(IEnumerable`1 targets)
   at Cake.Core.Scripting.ScriptHost.RunTargets(IEnumerable`1 targets)
   at Cake.Frosting.Internal.FrostingEngine`1.Run(IEnumerable`1 targets)
   at Cake.Frosting.Internal.DefaultCommand.Execute(CommandContext context, DefaultCommandSettings settings, CancellationToken cancellationToken)

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