Skip to content

Commit

Permalink
Merge pull request #173 from Microsoft/develop
Browse files Browse the repository at this point in the history
Create release
  • Loading branch information
heaths authored Jan 30, 2019
2 parents 725b7a3 + d9dbe79 commit 91f4c1d
Show file tree
Hide file tree
Showing 49 changed files with 1,458 additions and 289 deletions.
11 changes: 8 additions & 3 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ trigger:
branches:
include:
- master
- develop
paths:
exclude:
- README.md

pr: none

queue:
name: VSEng-MicroBuildVS2017
timeoutInMinutes: 120
demands:
- msbuild
- visualstudio
- vstest
- ChocolateyInstall
- MSBuild
- VisualStudio
- VSTest

steps:
- task: ms-vseng.MicroBuildTasks.30666190-6959-11e5-9f96-f56098202fef.MicroBuildSigningPlugin@1
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ Visual Studio Locator
=====================

![build status: master](https://devdiv.visualstudio.com/DevDiv/_apis/build/status/Setup/Setup-vswhere-CI?branchName=master&label=master)
[![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)
[![github release](https://img.shields.io/github/release/Microsoft/vswhere.svg?logo=github)](https://github.com/Microsoft/vswhere/releases/latest)
[![github releases: all](https://img.shields.io/github/downloads/Microsoft/vswhere/total.svg?logo=github&label=github)](https://github.com/Microsoft/vswhere/releases)
[![chocolatey: all](https://img.shields.io/chocolatey/dt/vswhere.svg)](https://chocolatey.org/packages/vswhere)
[![nuget: all](https://img.shields.io/nuget/dt/vswhere.svg?label=nuget)](https://nuget.org/packages/vswhere)
![build status: develop](https://devdiv.visualstudio.com/DevDiv/_apis/build/status/Setup/Setup-vswhere-CI?branchName=develop&label=develop)
[![github release](https://img.shields.io/github/release/Microsoft/vswhere.svg?logo=github&logoColor=white)](https://github.com/Microsoft/vswhere/releases/latest)
[![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)
[![nuget: all](https://img.shields.io/nuget/dt/vswhere.svg?logo=nuget&logoColor=white&label=nuget)](https://nuget.org/packages/vswhere)
[![chocolatey: all](https://img.shields.io/chocolatey/dt/vswhere.svg?label=chocolatey)](https://chocolatey.org/packages/vswhere)

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.

Expand Down
13 changes: 6 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.

trigger:
batch: true
branches:
include:
- develop
trigger: none

pr:
branches:
include:
- master
- develop
- master
- develop
paths:
exclude:
- README.md

pool:
vmImage: vs2017-win2016
Expand Down
114 changes: 114 additions & 0 deletions docker/Tests/find.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt in the project root for license information.

# Instances and results are sorted for consistency.
Describe 'vswhere -sort -find' {
BeforeAll {
# Always write to 32-bit registry key.
$key = New-Item -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\Setup\Reboot -Force
$null = $key | New-ItemProperty -Name 3 -Value 1 -Force

$files = @(
'MSBuild\15.0\Bin\MSBuild.exe'
'MSBuild\15.0\Bin\MSBuild.exe.config'
'MSBuild\15.0\Bin\amd64\MSBuild.exe'
'MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
)
# Populate each instance with files to find.
$instances = C:\bin\vswhere.exe -all -prerelease -products * -format json | ConvertFrom-Json
foreach ($file in $files) {
$filePath = Join-Path -Path $instances.installationPath -ChildPath $file
$null = New-Item -Path $filePath -ItemType 'File' -Value '1' -Force
}
}

Context 'msbuild\15.0\bin\msbuild.exe' {
It 'returns 2 matches' {
$files = C:\bin\vswhere.exe -sort -find 'msbuild\15.0\bin\msbuild.exe'

$files.Count | Should Be 2
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$files[1] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
}

It '-format json returns 2 matches' {
$files = C:\bin\vswhere.exe -sort -find 'msbuild\15.0\bin\msbuild.exe' -format json | ConvertFrom-Json

$files.Count | Should Be 2
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$files[1] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
}

It '-format xml returns 2 matches' {
$doc = [xml](C:\bin\vswhere.exe -sort -find 'msbuild\15.0\bin\msbuild.exe' -format xml)

$doc.files.file.Count | Should Be 2
$doc.files.file[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$doc.files.file[1] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
}
}

Context 'msbuild\**\msbuild.exe' {
It 'returns 4 matches' {
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.exe'

$files.Count | Should Be 4
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$files[2] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$files[3] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
}

It '-format json returns 4 matches' {
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.exe' -format json | ConvertFrom-Json

$files.Count | Should Be 4
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$files[2] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$files[3] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
}

It '-format xml returns 4 matches' {
$doc = [xml](C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.exe' -format xml)

$doc.files.file.Count | Should Be 4
$doc.files.file[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$doc.files.file[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$doc.files.file[2] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$doc.files.file[3] | Should Be 'C:\VS\Community\MSBuild\15.0\Bin\MSBuild.exe'
}
}

Context 'msbuild\**\msbuild.* -latest' {
It 'returns 4 matches' {
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.*' -latest

$files.Count | Should Be 4
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
$files[2] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$files[3] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.config'
}

It '-format json returns 4 matches' {
$files = C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.*' -latest -format json | ConvertFrom-Json

$files.Count | Should Be 4
$files[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$files[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
$files[2] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$files[3] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.config'
}

It '-format xml returns 4 matches' {
$doc = [xml](C:\bin\vswhere.exe -sort -find 'msbuild\**\msbuild.*' -latest -format xml)

$doc.files.file.Count | Should Be 4
$doc.files.file[0] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe'
$doc.files.file[1] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\amd64\MSBuild.exe.config'
$doc.files.file[2] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe'
$doc.files.file[3] | Should Be 'C:\VS\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.config'
}
}
}
15 changes: 11 additions & 4 deletions docker/Tests/vswhere.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ Describe 'vswhere' {
$instances = [xml](C:\bin\vswhere.exe -all -format xml)
$instances.instances.instance.Count | Should Be 3
}

It 'returns 1 instance where IsRebootRequired' {
# Make sure PowerShell converts to a collection of PSCustomObjects before filtering.
$instances = C:\bin\vswhere.exe -all -format json | ConvertFrom-Json

$instances = @($instances | Where-Object { $_.IsRebootRequired })
$instances.Count | Should Be 1
$instances[0].instanceId | Should Be 3
}
}

Context '-products' {
Expand Down Expand Up @@ -295,8 +304,7 @@ Describe 'vswhere' {

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion inc/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ steps:
condition: succeededOrFailed()

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

Expand Down
2 changes: 1 addition & 1 deletion pkg/vswhere/vswhere.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<packageSourceUrl>https://github.com/Microsoft/vswhere/tree/$CommitId$/pkg/vswhere</packageSourceUrl>
<docsUrl>https://github.com/Microsoft/vswhere/wiki</docsUrl>
<bugTrackerUrl>https://github.com/Microsoft/vswhere/issues</bugTrackerUrl>
<releaseNotes>https://github.com/Microsoft/vswhere/releases/tag/$Version$</releaseNotes>
<releaseNotes>https://github.com/Microsoft/vswhere/releases/tag/$Tag$</releaseNotes>
</metadata>
<files>
<file src="build\vswhere.props" target="build\"/>
Expand Down
22 changes: 21 additions & 1 deletion src/vswhere.lib/CommandArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
{
m_latest = true;
}
else if (ArgumentEquals(arg.Value, L"sort"))
{
m_sort = true;
}
else if (ArgumentEquals(arg.Value, L"legacy"))
{
m_legacy = true;
Expand All @@ -106,8 +110,24 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
}
else if (ArgumentEquals(arg.Value, L"property"))
{
if (m_find.length())
{
auto message = ResourceManager::FormatString(IDS_E_ARGINCOMPAT, L"property", L"find");
throw win32_error(ERROR_INVALID_PARAMETER, message);
}

m_property = ParseArgument(it, args.end(), arg);
}
else if (ArgumentEquals(arg.Value, L"find"))
{
if (m_property.length())
{
auto message = ResourceManager::FormatString(IDS_E_ARGINCOMPAT, L"find", L"property");
throw win32_error(ERROR_INVALID_PARAMETER, message);
}

m_find = ParseArgument(it, args.end(), arg);
}
else if (ArgumentEquals(arg.Value, L"nologo"))
{
m_nologo = true;
Expand Down Expand Up @@ -146,7 +166,7 @@ void CommandArgs::Parse(_In_ vector<CommandParser::Token> args)
}
}

if (!m_property.empty() && m_format.empty())
if ((m_property.length() || m_find.length()) && m_format.empty())
{
m_format = L"value";
}
Expand Down
14 changes: 14 additions & 0 deletions src/vswhere.lib/CommandArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class CommandArgs
m_requires(obj.m_requires),
m_version(obj.m_version),
m_latest(obj.m_latest),
m_sort(obj.m_sort),
m_legacy(obj.m_legacy),
m_prerelease(obj.m_prerelease),
m_format(obj.m_format),
m_property(obj.m_property),
m_find(obj.m_find),
m_nologo(obj.m_nologo),
m_utf8(obj.m_utf8),
m_help(obj.m_help)
Expand Down Expand Up @@ -80,6 +82,11 @@ class CommandArgs
return m_latest;
}

const bool get_Sort() const noexcept
{
return m_sort;
}

const bool get_Legacy() const noexcept
{
return m_legacy;
Expand All @@ -105,6 +112,11 @@ class CommandArgs
return m_property;
}

const std::wstring& get_Find() const noexcept
{
return m_find;
}

const bool get_Logo() const noexcept
{
return !m_nologo;
Expand Down Expand Up @@ -139,10 +151,12 @@ class CommandArgs
bool m_requiresAny;
std::wstring m_version;
bool m_latest;
bool m_sort;
bool m_legacy;
bool m_prerelease;
std::wstring m_format;
std::wstring m_property;
std::wstring m_find;
bool m_nologo;
bool m_utf8;
bool m_help;
Expand Down
Loading

0 comments on commit 91f4c1d

Please sign in to comment.