Skip to content

Commit 1926c46

Browse files
authored
VsDev: reject VS instances which do not actually contain devshell/devcmd (#19352)
Closes #19169
1 parent 46b9572 commit 1926c46

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/cascadia/TerminalSettingsModel/VsDevCmdGenerator.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ namespace winrt::Microsoft::Terminal::Settings::Model
2626
void GenerateProfiles(const VsSetupConfiguration::VsSetupInstance& instance, bool hidden, std::vector<winrt::com_ptr<implementation::Profile>>& profiles) const override;
2727

2828
private:
29-
bool IsInstanceValid(const VsSetupConfiguration::VsSetupInstance&) const
29+
bool IsInstanceValid(const VsSetupConfiguration::VsSetupInstance& instance) const
3030
{
3131
// We only support version of VS from 15.0.
3232
// Per heaths: The [ISetupConfiguration] COM server only supports Visual Studio 15.0 and newer anyway.
3333
// Eliding the version range will improve the discovery performance by not having to parse or compare the versions.
34-
return true;
34+
std::error_code ec;
35+
return std::filesystem::exists(GetDevCmdScriptPath(instance), ec) && !ec;
3536
}
3637

3738
std::wstring GetProfileGuidSeed(const VsSetupConfiguration::VsSetupInstance& instance) const

src/cascadia/TerminalSettingsModel/VsDevShellGenerator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model
2828
private:
2929
bool IsInstanceValid(const VsSetupConfiguration::VsSetupInstance& instance) const
3030
{
31-
return instance.VersionInRange(L"[16.2,)");
31+
std::error_code ec;
32+
return instance.VersionInRange(L"[16.2,)") && std::filesystem::exists(GetDevShellModulePath(instance), ec) && !ec;
3233
}
3334

3435
std::wstring GetProfileGuidSeed(const VsSetupConfiguration::VsSetupInstance& instance) const

0 commit comments

Comments
 (0)