Skip to content

Commit 12c8f71

Browse files
authored
Merge pull request #43 from Microsoft/develop
Create new release
2 parents bdd4404 + d2eec55 commit 12c8f71

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

docker/Tests/legacy.tests.ps1

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,39 @@ Describe 'vswhere -legacy' {
5151
$instances.Count | Should Be 2
5252
}
5353
}
54+
55+
Context 'no instances' {
56+
BeforeEach {
57+
New-Item HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 -Force | ForEach-Object {
58+
foreach ($version in '10.0', '14.0') {
59+
$_ | New-ItemProperty -Name $version -Value "C:\VisualStudio\$version" -Force
60+
}
61+
}
62+
63+
Start-Process -Wait -FilePath C:\Windows\SysWOW64\regsvr32.exe -ArgumentList @(
64+
'/s',
65+
'/u',
66+
'C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Native.dll'
67+
)
68+
}
69+
70+
AfterEach {
71+
Start-Process -Wait -FilePath C:\Windows\SysWOW64\regsvr32.exe -ArgumentList @(
72+
'/s',
73+
'C:\Downloads\Microsoft.VisualStudio.Setup.Configuration.Native\tools\x86\Microsoft.VisualStudio.Setup.Configuration.Native.dll'
74+
)
75+
}
76+
77+
It 'returns 2 instances' {
78+
$instances = C:\bin\vswhere.exe -legacy -format json | ConvertFrom-Json
79+
$instances.Count | Should Be 2
80+
}
81+
82+
It '-latest returns latest instance' {
83+
$instances = C:\bin\vswhere.exe -legacy -latest -format json | ConvertFrom-Json
84+
$instances.Count | Should Be 1
85+
$instances[0].instanceId | Should Be 'VisualStudio.14.0'
86+
$instances[0].installationPath | Should Be 'C:\VisualStudio\14.0'
87+
}
88+
}
5489
}

src/vswhere.lib/Formatter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Formatter::Formatter()
2424

2525
Formatter::FormatterMap Formatter::Formatters =
2626
{
27-
{ L"json", make_tuple(IDS_FORMAT_TEXT, JsonFormatter::Create) },
28-
{ L"text", make_tuple(IDS_FORMAT_JSON, TextFormatter::Create) },
27+
{ L"json", make_tuple(IDS_FORMAT_JSON, JsonFormatter::Create) },
28+
{ L"text", make_tuple(IDS_FORMAT_TEXT, TextFormatter::Create) },
2929
{ L"value", make_tuple(IDS_FORMAT_VALUE, ValueFormatter::Create) },
3030
{ L"xml", make_tuple(IDS_FORMAT_XML, XmlFormatter::Create) },
3131
};

src/vswhere.lib/InstanceSelector.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ InstanceSelector::InstanceSelector(_In_ const CommandArgs& args, _In_ ILegacyPro
3333

3434
bool InstanceSelector::Less(const ISetupInstancePtr& a, const ISetupInstancePtr& b) const
3535
{
36-
static ci_equal equal;
3736
static ci_less less;
3837

3938
bstr_t bstrVersionA, bstrVersionB;
@@ -62,6 +61,12 @@ bool InstanceSelector::Less(const ISetupInstancePtr& a, const ISetupInstancePtr&
6261
return SUCCEEDED(hrB);
6362
}
6463
}
64+
else
65+
{
66+
// If ISetupHelper is not available we have only legacy products, or very early pre-releases of VS2017.
67+
// For version 10.0 and newer either should lexigraphically sort correctly.
68+
return less(wstring(bstrVersionA), wstring(bstrVersionB));
69+
}
6570
}
6671
else
6772
{

0 commit comments

Comments
 (0)