Skip to content

Commit 91f4c1d

Browse files
authored
Merge pull request #173 from Microsoft/develop
Create release
2 parents 725b7a3 + d9dbe79 commit 91f4c1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1458
-289
lines changed

.vsts-ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,21 @@ trigger:
66
branches:
77
include:
88
- master
9+
- develop
10+
paths:
11+
exclude:
12+
- README.md
913

1014
pr: none
1115

1216
queue:
1317
name: VSEng-MicroBuildVS2017
1418
timeoutInMinutes: 120
1519
demands:
16-
- msbuild
17-
- visualstudio
18-
- vstest
20+
- ChocolateyInstall
21+
- MSBuild
22+
- VisualStudio
23+
- VSTest
1924

2025
steps:
2126
- task: ms-vseng.MicroBuildTasks.30666190-6959-11e5-9f96-f56098202fef.MicroBuildSigningPlugin@1

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ Visual Studio Locator
22
=====================
33

44
![build status: master](https://devdiv.visualstudio.com/DevDiv/_apis/build/status/Setup/Setup-vswhere-CI?branchName=master&label=master)
5-
[![build status: develop](https://dev.azure.com/azure-public/vssetup/_apis/build/status/Microsoft.vswhere?branchName=develop&label=develop)](https://dev.azure.com/azure-public/vssetup/_build/latest?definitionId=20?branchName=develop)
6-
[![github release](https://img.shields.io/github/release/Microsoft/vswhere.svg?logo=github)](https://github.com/Microsoft/vswhere/releases/latest)
7-
[![github releases: all](https://img.shields.io/github/downloads/Microsoft/vswhere/total.svg?logo=github&label=github)](https://github.com/Microsoft/vswhere/releases)
8-
[![chocolatey: all](https://img.shields.io/chocolatey/dt/vswhere.svg)](https://chocolatey.org/packages/vswhere)
9-
[![nuget: all](https://img.shields.io/nuget/dt/vswhere.svg?label=nuget)](https://nuget.org/packages/vswhere)
5+
![build status: develop](https://devdiv.visualstudio.com/DevDiv/_apis/build/status/Setup/Setup-vswhere-CI?branchName=develop&label=develop)
6+
[![github release](https://img.shields.io/github/release/Microsoft/vswhere.svg?logo=github&logoColor=white)](https://github.com/Microsoft/vswhere/releases/latest)
7+
[![github releases: all](https://img.shields.io/github/downloads/Microsoft/vswhere/total.svg?logo=github&logoColor=white&label=github)](https://github.com/Microsoft/vswhere/releases)
8+
[![nuget: all](https://img.shields.io/nuget/dt/vswhere.svg?logo=nuget&logoColor=white&label=nuget)](https://nuget.org/packages/vswhere)
9+
[![chocolatey: all](https://img.shields.io/chocolatey/dt/vswhere.svg?label=chocolatey)](https://chocolatey.org/packages/vswhere)
1010

1111
Over the years Visual Studio could be discovered using registry keys, but with recent changes to the deployment and extensibility models a new method is needed to discover possibly more than once installed instance. These changes facilitate a smaller, faster default install complimented by on-demand install of other workloads and components.
1212

azure-pipelines.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
# Copyright (C) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.
33

4-
trigger:
5-
batch: true
6-
branches:
7-
include:
8-
- develop
4+
trigger: none
95

106
pr:
117
branches:
128
include:
13-
- master
14-
- develop
9+
- master
10+
- develop
11+
paths:
12+
exclude:
13+
- README.md
1514

1615
pool:
1716
vmImage: vs2017-win2016

docker/Tests/find.tests.ps1

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Copyright (C) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.
3+
4+
# Instances and results are sorted for consistency.
5+
Describe 'vswhere -sort -find' {
6+
BeforeAll {
7+
# Always write to 32-bit registry key.
8+
$key = New-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\Setup\Reboot -Force
9+
$null = $key | New-ItemProperty -Name 3 -Value 1 -Force
10+
11+
$files = @(
12+
'MSBuild\15.0\Bin\MSBuild.exe'
13+
'MSBuild\15.0\Bin\MSBuild.exe.config'
14+
'MSBuild\15.0\Bin\amd64\MSBuild.exe'
15+
'MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
16+
)
17+
# Populate each instance with files to find.
18+
$instances = C:\bin\vswhere.exe -all -prerelease -products * -format json | ConvertFrom-Json
19+
foreach ($file in $files) {
20+
$filePath = Join-Path -Path $instances.installationPath -ChildPath $file
21+
$null = New-Item -Path $filePath -ItemType 'File' -Value '1' -Force
22+
}
23+
}
24+
25+
Context 'msbuild\15.0\bin\msbuild.exe' {
26+
It 'returns 2 matches' {
27+
$files = C:\bin\vswhere.exe -sort -find 'msbuild\15.0\bin\msbuild.exe'
28+
29+
$files.Count | Should Be 2
30+
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
31+
$files[1] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
32+
}
33+
34+
It '-format json returns 2 matches' {
35+
$files = C:\bin\vswhere.exe -sort -find 'msbuild\15.0\bin\msbuild.exe' -format json | ConvertFrom-Json
36+
37+
$files.Count | Should Be 2
38+
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
39+
$files[1] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
40+
}
41+
42+
It '-format xml returns 2 matches' {
43+
$doc = [xml](C:\bin\vswhere.exe -sort -find 'msbuild\15.0\bin\msbuild.exe' -format xml)
44+
45+
$doc.files.file.Count | Should Be 2
46+
$doc.files.file[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
47+
$doc.files.file[1] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
48+
}
49+
}
50+
51+
Context 'msbuild\**\msbuild.exe' {
52+
It 'returns 4 matches' {
53+
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.exe'
54+
55+
$files.Count | Should Be 4
56+
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
57+
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
58+
$files[2] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe'
59+
$files[3] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
60+
}
61+
62+
It '-format json returns 4 matches' {
63+
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.exe' -format json | ConvertFrom-Json
64+
65+
$files.Count | Should Be 4
66+
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
67+
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
68+
$files[2] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe'
69+
$files[3] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
70+
}
71+
72+
It '-format xml returns 4 matches' {
73+
$doc = [xml](C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.exe' -format xml)
74+
75+
$doc.files.file.Count | Should Be 4
76+
$doc.files.file[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
77+
$doc.files.file[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
78+
$doc.files.file[2] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe'
79+
$doc.files.file[3] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
80+
}
81+
}
82+
83+
Context 'msbuild\**\msbuild.* -latest' {
84+
It 'returns 4 matches' {
85+
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.*' -latest
86+
87+
$files.Count | Should Be 4
88+
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
89+
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
90+
$files[2] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
91+
$files[3] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.config'
92+
}
93+
94+
It '-format json returns 4 matches' {
95+
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.*' -latest -format json | ConvertFrom-Json
96+
97+
$files.Count | Should Be 4
98+
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
99+
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
100+
$files[2] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
101+
$files[3] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.config'
102+
}
103+
104+
It '-format xml returns 4 matches' {
105+
$doc = [xml](C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.*' -latest -format xml)
106+
107+
$doc.files.file.Count | Should Be 4
108+
$doc.files.file[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
109+
$doc.files.file[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
110+
$doc.files.file[2] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
111+
$doc.files.file[3] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.config'
112+
}
113+
}
114+
}

docker/Tests/vswhere.tests.ps1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ Describe 'vswhere' {
103103
$instances = [xml](C:\bin\vswhere.exe -all -format xml)
104104
$instances.instances.instance.Count | Should Be 3
105105
}
106+
107+
It 'returns 1 instance where IsRebootRequired' {
108+
# Make sure PowerShell converts to a collection of PSCustomObjects before filtering.
109+
$instances = C:\bin\vswhere.exe -all -format json | ConvertFrom-Json
110+
111+
$instances = @($instances | Where-Object { $_.IsRebootRequired })
112+
$instances.Count | Should Be 1
113+
$instances[0].instanceId | Should Be 3
114+
}
106115
}
107116

108117
Context '-products' {
@@ -295,8 +304,7 @@ Describe 'vswhere' {
295304

296305
It 'returns 0 instances using "json"' {
297306
$instances = C:\bin\vswhere.exe -property invalid -format json | ConvertFrom-Json
298-
$instances.Count | Should Be 2
299-
$instances | ForEach-Object { $_.instanceId | Should BeNullOrEmpty }
307+
$instances.Count | Should Be 0
300308
}
301309

302310
It 'returns 0 instances using "value"' {
@@ -306,8 +314,7 @@ Describe 'vswhere' {
306314

307315
It 'returns 0 instances using "xml"' {
308316
$instances = [xml](C:\bin\vswhere.exe -property invalid -format xml)
309-
@($instances.instances.instance).Count | Should Be 2
310-
@($instances.instances.instance) | ForEach-Object { $_.instanceId | Should BeNullOrEmpty }
317+
$instances.instances.instance.Count | Should Be 0
311318
}
312319
}
313320

inc/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ steps:
7070
condition: succeededOrFailed()
7171

7272
- script: |
73-
choco pack pkg\vswhere\vswhere.nuspec --out "bin\${{ parameters.BuildConfiguration }}" --version "%GitBuildVersionSimple%" "Configuration=${{ parameters.BuildConfiguration }}" "CommitId=$(Build.SourceVersion)"
73+
choco pack pkg\vswhere\vswhere.nuspec --out "bin\${{ parameters.BuildConfiguration }}" --version "%NBGV_NuGetPackageVersion%" "Configuration=${{ parameters.BuildConfiguration }}" "CommitId=$(Build.SourceVersion)" "Tag=$(Build.BuildNumber)"
7474
displayName: Package
7575
workingDirectory: $(Build.SourcesDirectory)
7676

pkg/vswhere/vswhere.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<packageSourceUrl>https://github.com/Microsoft/vswhere/tree/$CommitId$/pkg/vswhere</packageSourceUrl>
2020
<docsUrl>https://github.com/Microsoft/vswhere/wiki</docsUrl>
2121
<bugTrackerUrl>https://github.com/Microsoft/vswhere/issues</bugTrackerUrl>
22-
<releaseNotes>https://github.com/Microsoft/vswhere/releases/tag/$Version$</releaseNotes>
22+
<releaseNotes>https://github.com/Microsoft/vswhere/releases/tag/$Tag$</releaseNotes>
2323
</metadata>
2424
<files>
2525
<file src="build\vswhere.props" target="build\"/>

src/vswhere.lib/CommandArgs.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
8181
{
8282
m_latest = true;
8383
}
84+
else if (ArgumentEquals(arg.Value, L"sort"))
85+
{
86+
m_sort = true;
87+
}
8488
else if (ArgumentEquals(arg.Value, L"legacy"))
8589
{
8690
m_legacy = true;
@@ -106,8 +110,24 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
106110
}
107111
else if (ArgumentEquals(arg.Value, L"property"))
108112
{
113+
if (m_find.length())
114+
{
115+
auto message = ResourceManager::FormatString(IDS_E_ARGINCOMPAT, L"property", L"find");
116+
throw win32_error(ERROR_INVALID_PARAMETER, message);
117+
}
118+
109119
m_property = ParseArgument(it, args.end(), arg);
110120
}
121+
else if (ArgumentEquals(arg.Value, L"find"))
122+
{
123+
if (m_property.length())
124+
{
125+
auto message = ResourceManager::FormatString(IDS_E_ARGINCOMPAT, L"find", L"property");
126+
throw win32_error(ERROR_INVALID_PARAMETER, message);
127+
}
128+
129+
m_find = ParseArgument(it, args.end(), arg);
130+
}
111131
else if (ArgumentEquals(arg.Value, L"nologo"))
112132
{
113133
m_nologo = true;
@@ -146,7 +166,7 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
146166
}
147167
}
148168

149-
if (!m_property.empty() && m_format.empty())
169+
if ((m_property.length() || m_find.length()) && m_format.empty())
150170
{
151171
m_format = L"value";
152172
}

src/vswhere.lib/CommandArgs.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ class CommandArgs
3030
m_requires(obj.m_requires),
3131
m_version(obj.m_version),
3232
m_latest(obj.m_latest),
33+
m_sort(obj.m_sort),
3334
m_legacy(obj.m_legacy),
3435
m_prerelease(obj.m_prerelease),
3536
m_format(obj.m_format),
3637
m_property(obj.m_property),
38+
m_find(obj.m_find),
3739
m_nologo(obj.m_nologo),
3840
m_utf8(obj.m_utf8),
3941
m_help(obj.m_help)
@@ -80,6 +82,11 @@ class CommandArgs
8082
return m_latest;
8183
}
8284

85+
const bool get_Sort() const noexcept
86+
{
87+
return m_sort;
88+
}
89+
8390
const bool get_Legacy() const noexcept
8491
{
8592
return m_legacy;
@@ -105,6 +112,11 @@ class CommandArgs
105112
return m_property;
106113
}
107114

115+
const std::wstring& get_Find() const noexcept
116+
{
117+
return m_find;
118+
}
119+
108120
const bool get_Logo() const noexcept
109121
{
110122
return !m_nologo;
@@ -139,10 +151,12 @@ class CommandArgs
139151
bool m_requiresAny;
140152
std::wstring m_version;
141153
bool m_latest;
154+
bool m_sort;
142155
bool m_legacy;
143156
bool m_prerelease;
144157
std::wstring m_format;
145158
std::wstring m_property;
159+
std::wstring m_find;
146160
bool m_nologo;
147161
bool m_utf8;
148162
bool m_help;

0 commit comments

Comments
 (0)