Fix MSBuild toolset/SDK detection under Wine

msbuild <project>.vcxproj previously failed with MSB8020 ("build tools for
vNNN cannot be found") because MSBuild's own toolset/SDK resolution reads
a different set of environment variables than cl/link/lib do directly
(VCInstallDir_<N>, VCToolsInstallDir_<N>, VsInstallRoot,
WindowsSdkDir_10, WindowsTargetPlatformVersion, DisableRegistryUse, etc) -
none of which the generic INCLUDE/LIB/WINEPATH env covered.

Added msbuildEnv, populated for every MSBuild toolset generation actually
present under MSBuild/Microsoft/VC/v*, and wired into the msbuild wrapper.

Verified end-to-end: msbuild successfully builds ocornut/imgui's
example_win32_directx11.vcxproj (retargeted from its original v141
PlatformToolset to this install's v145) - compiles all 8 sources and
links against d3d11.lib/d3dcompiler.lib/dxgi.lib, producing a valid
PE32+ executable.
This commit is contained in:
Cheviiot
2026-07-25 01:58:18 +10:00
parent 8f52e5861a
commit 867c915596
3 changed files with 107 additions and 2 deletions
+13
View File
@@ -16,6 +16,14 @@ type Paths struct {
SDKBinDir string // <dest>/kits/10/bin/<sdkver>/<host> - mc/midl/mt/rc live here
MSBuildBinDir string // <dest>/MSBuild/Current/Bin/<dotnetHost> - MSBuild.exe lives here
// Windows-notation ("z:\...") equivalents of the paths above, needed to
// populate the MSBuild-specific environment variables its toolset/SDK
// detection props read (see msbuildEnv in the wrapper package).
BaseWin string // z:\<dest>
MSVCBaseWin string // z:\<dest>\vc
MSVCDirWin string // z:\<dest>\vc\tools\msvc\<ver>
SDKBaseWin string // z:\<dest>\kits\10
Include string
Lib string
LibPath string
@@ -89,6 +97,11 @@ func NewPaths(cfg *Config, baseUnix string) *Paths {
SDKBinDir: sdkBinDir,
MSBuildBinDir: msbuildBinDir,
BaseWin: winBase,
MSVCBaseWin: msvcBase,
MSVCDirWin: msvcDirWin,
SDKBaseWin: sdkBase,
Include: include,
Lib: lib,
LibPath: lib,