From e006889d41b31d553cb9a42f6d34a4514bb0eb06 Mon Sep 17 00:00:00 2001 From: Edison Henrique Andreassy Date: Fri, 19 Jun 2026 11:35:30 -0300 Subject: [PATCH] feat(sdk): support building web projects with the dotnet CLI (Core MSBuild) Make `dotnet build` work for ASP.NET 4.x projects when Visual Studio or the Build Tools (web workload) is installed; the full-MSBuild path is unchanged. - Locate Microsoft.WebApplication.targets from the installed VS/Build Tools when the default path is missing (fixes MSB4019), with a clear SYSWEB001 error if none is found. - Skip MvcBuildViews under Core MSBuild (AspNetCompiler is unavailable, MSB4803) instead of failing Release. - Re-add the System.Web reference after the Microsoft.NET.Sdk import for Core MSBuild, where the earlier reference is dropped from @(Reference). --- src/MSBuild.SDK.SystemWeb/Sdk/Sdk.targets | 64 ++++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/MSBuild.SDK.SystemWeb/Sdk/Sdk.targets b/src/MSBuild.SDK.SystemWeb/Sdk/Sdk.targets index d7b0dbd..c57447f 100644 --- a/src/MSBuild.SDK.SystemWeb/Sdk/Sdk.targets +++ b/src/MSBuild.SDK.SystemWeb/Sdk/Sdk.targets @@ -7,23 +7,83 @@ false - + + + + + + + 15.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) $(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets + + + + <_SystemWebVSDir Condition="'$(ProgramW6432)' != ''">$(ProgramW6432)\Microsoft Visual Studio + <_SystemWebVSDir Condition="!Exists('$(_SystemWebVSDir)') and '$(MSBuildProgramFiles32)' != ''">$(MSBuildProgramFiles32)\Microsoft Visual Studio + + + <_SystemWebVSYear Condition="Exists('$(_SystemWebVSDir)')">$([System.IO.Directory]::GetDirectories('$(_SystemWebVSDir)')) + <_SystemWebVSYear Condition="$(_SystemWebVSYear.Contains(';'))">$(_SystemWebVSYear.Substring(0, $(_SystemWebVSYear.IndexOf(';')))) + + + <_SystemWebVSEdition Condition="'$(_SystemWebVSYear)' != '' and Exists('$(_SystemWebVSYear)')">$([System.IO.Directory]::GetDirectories('$(_SystemWebVSYear)')) + <_SystemWebVSEdition Condition="$(_SystemWebVSEdition.Contains(';'))">$(_SystemWebVSEdition.Substring(0, $(_SystemWebVSEdition.IndexOf(';')))) + + <_SystemWebVSCandidate Condition="'$(_SystemWebVSEdition)' != ''">$(_SystemWebVSEdition)\MSBuild\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets + $(_SystemWebVSCandidate) + + + + + + + - + + + + + +