Skip to content

Commit 77a1f5a

Browse files
committed
VsDev: reject VS instances which do not actually contain devshell/devcmd (#19352)
Closes #19169 (cherry picked from commit 1926c46) Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdI3eE Service-Version: 1.23
1 parent f486a5f commit 77a1f5a

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)