Implement dynamic support for VSDevCmd profiles #14635

Open
opened 2026-01-31 04:15:33 +00:00 by claunia · 0 comments
Owner

Originally created by @heaths on GitHub (Jul 22, 2021).

I see a lot of developers adding entries to start the Visual Studio Developer Command Prompt, but its location can vary from machine to machine and multiple instances may be installed.

You can use the ISetupConfiguration COM server (the server is actually native, which is what we use in https://github.com/microsoft/vswhere) to find instances, which populate instances automatically if 1) installed, and 2) any instances are present.

A profile source could be something like VisualStudio_<InstanceId>. If the COM server can be created - ignoring REGDB_E_CLASSNOTREG - instances can be enumerated and command lines inferred from Common7\Tools\VSDevCmd.bat. As with any other dynamically discovered profile any number of profiles could be disabled.

The COM server supports Visual Studio 2017 and newer, but as with vswhere, older versions could be supported, though, IIRC, the actual batch file name and perhaps where it is located is different.

Originally created by @heaths on GitHub (Jul 22, 2021). I see a lot of developers adding entries to start the Visual Studio Developer Command Prompt, but its location can vary from machine to machine and multiple instances may be installed. You can use the [`ISetupConfiguration` COM server](https://docs.microsoft.com/dotnet/api/microsoft.visualstudio.setup.configuration.isetupconfiguration) (the server is actually native, which is what we use in https://github.com/microsoft/vswhere) to find instances, which populate instances automatically if 1) installed, and 2) any instances are present. A profile `source` could be something like `VisualStudio_<InstanceId>`. If the COM server can be created - ignoring `REGDB_E_CLASSNOTREG` - instances can be enumerated and command lines inferred from `Common7\Tools\VSDevCmd.bat`. As with any other dynamically discovered profile any number of profiles could be disabled. The COM server supports Visual Studio 2017 and newer, but [as with vswhere](https://github.com/microsoft/vswhere/blob/5d250b95a2c4d312961ed4e811fe240db197c404/src/vswhere.lib/InstanceSelector.cpp#L125-L142), older versions could be supported, though, IIRC, the actual batch file name and perhaps where it is located is different.
claunia added the Issue-FeatureResolution-Duplicate labels 2026-01-31 04:15:33 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14635