Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building metadata projects outside vscmd results in failure to find cl.exe #1854

Open
riverar opened this issue Feb 24, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@riverar
Copy link
Collaborator

riverar commented Feb 24, 2024

Just creating an official issue to track fixing a long time annoyance. dotnet build in a vanilla Terminal session results in midl.exe/cl.exe failures due to tooling paths not getting wired up correctly.

@ChrisDenton
Copy link
Contributor

Should be possible to use vswhere to find the exes for us?

@riverar
Copy link
Collaborator Author

riverar commented Feb 24, 2024

The Microsoft.Windows.WinmdGenerator SDK already pulls in Microsoft.Windows.SDK.CPP, i.e.:

<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.CPP" Version="10.0.19041.5" GeneratePathProperty="true"/>
<PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="10.0.19041.202-preview" GeneratePathProperty="true"/>
</ItemGroup>

Which sets a bunch of properties, some of which we rely upon (e.g. WindowsSDKVersionedBinRoot to find midl.exe):

<CompileIdls
Idls="@(Idls)"
ObjDir="$(ObjDir)"
CompiledHeadersDir="$(CompiledHeadersDir)"
ScriptsDir="$(ScriptsDir)"
SdkIncRoot="$(SdkIncRoot)"
SdkBinDir="$(WindowsSDKVersionedBinRoot)"
AdditionalIncludes="$(AdditionalIncludes)"
MidlSwitches="$(MidlSwitches)"
MSBuildProjectDirectory="$(MSBuildProjectDirectory)"/>

But then we also have these properties to contend with:

<Win32MetadataSdkRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..'))</Win32MetadataSdkRoot>
<TaskBinDir Condition="'$(TaskBinDir)' == ''">$(Win32MetadataSdkRoot)\tools\net8.0</TaskBinDir>
<ToolsBinDir Condition="'$(ToolsBinDir)' == ''">$(Win32MetadataSdkRoot)\tools\net8.0</ToolsBinDir>
<LibToolsBinDir Condition="'$(LibToolsBinDir)' == ''">$(Win32MetadataSdkRoot)\tools</LibToolsBinDir>
<ScriptsDir Condition="'$(ScriptsDir)' == ''">$(Win32MetadataSdkRoot)\scripts</ScriptsDir>
<ObjDir Condition="'$(ObjDir)' == ''">$(MSBuildProjectDirectory)\obj</ObjDir>
<CompiledHeadersDir Condition="'$(CompiledHeadersDir)' == ''">$(ObjDir)\CompiledHeaders</CompiledHeadersDir>
<SdkIncRoot>$(TargetPlatformSdkRootOverride)\include\$(TargetPlatformVersion)</SdkIncRoot>

And... that's as far as I've gotten at the moment. We just need to spend a bit more time following all the wires around, see what we've got, determine what *.SDK.CPP offers, and hopefully clean things up a bit so that we're working with a properly hydrated build environment.

@riverar riverar added the enhancement New feature or request label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants