-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support detection of legacy VS products
Resolves issues #24
- Loading branch information
Showing
23 changed files
with
787 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright (C) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE.txt in the project root for license information. | ||
|
||
Describe 'vswhere -legacy' { | ||
BeforeEach { | ||
# Make sure localized values are returned consistently across machines. | ||
$enu = [System.Globalization.CultureInfo]::GetCultureInfo('en-US') | ||
|
||
[System.Globalization.CultureInfo]::CurrentCulture = $enu | ||
[System.Globalization.CultureInfo]::CurrentUICulture = $enu | ||
} | ||
|
||
AfterEach { | ||
# Make sure the registry is cleaned up. | ||
Remove-Item HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 -Force -ErrorAction 'SilentlyContinue' | ||
} | ||
|
||
Context 'no legacy' { | ||
It 'returns 2 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 2 | ||
} | ||
} | ||
|
||
Context 'has legacy' { | ||
BeforeEach { | ||
New-Item HKLM:\Software\WOW6432Node\Microsoft\VisualStudio\SxS\VS7 -Force | ForEach-Object { | ||
foreach ($version in '10.0', '14.0') { | ||
$_ | New-ItemProperty -Name $version -Value "C:\VisualStudio\$version" -Force | ||
} | ||
} | ||
} | ||
|
||
It 'returns 4 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 4 | ||
} | ||
|
||
It '-version "10.0" returns 4 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -version '10.0' -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 4 | ||
} | ||
|
||
It '-version "14.0" returns 3 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -version '14.0' -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 3 | ||
} | ||
|
||
It '-version "[10.0,15.0)" returns 2 instances' { | ||
$instances = C:\bin\vswhere.exe -legacy -version '[10.0,15.0)' -format json | ConvertFrom-Json | ||
$instances.Count | Should Be 2 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// <copyright file="ILegacyProvider.h" company="Microsoft Corporation"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt in the project root for license information. | ||
// </copyright> | ||
|
||
#pragma once | ||
|
||
class ILegacyProvider | ||
{ | ||
public: | ||
virtual bool HasLegacyInstances() const = 0; | ||
virtual bool TryGetLegacyInstance(_In_ LPCWSTR wzVersion, _Out_ ISetupInstance** ppInstance) const = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
// <copyright file="LegacyInstance.cpp" company="Microsoft Corporation"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt in the project root for license information. | ||
// </copyright> | ||
|
||
#include "stdafx.h" | ||
|
||
using namespace std; | ||
|
||
template <class T> | ||
inline HRESULT NotImplemented(_In_ T* p) | ||
{ | ||
if (!p) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*p = NULL; | ||
return E_NOTFOUND; | ||
} | ||
|
||
template<> | ||
inline HRESULT NotImplemented(_In_ LPFILETIME pft) | ||
{ | ||
if (!pft) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
::SecureZeroMemory(pft, sizeof(FILETIME)); | ||
return E_NOTFOUND; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstanceId( | ||
_Out_ BSTR* pbstrInstanceId | ||
) | ||
{ | ||
if (!pbstrInstanceId) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*pbstrInstanceId = NULL; | ||
|
||
// Let exceptions throw since we're not a "true" COM object. | ||
wstring instanceId(L"VisualStudio."); | ||
instanceId += m_version; | ||
|
||
*pbstrInstanceId = ::SysAllocString(instanceId.c_str()); | ||
if (!pbstrInstanceId) | ||
{ | ||
return E_OUTOFMEMORY; | ||
} | ||
|
||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallDate( | ||
_Out_ LPFILETIME pInstallDate | ||
) | ||
{ | ||
return NotImplemented(pInstallDate); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallationName( | ||
_Out_ BSTR* pbstrInstallationName | ||
) | ||
{ | ||
return NotImplemented(pbstrInstallationName); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallationPath( | ||
_Out_ BSTR* pbstrInstallationPath | ||
) | ||
{ | ||
if (!pbstrInstallationPath) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*pbstrInstallationPath = ::SysAllocString(m_path.c_str()); | ||
if (!pbstrInstallationPath) | ||
{ | ||
return E_OUTOFMEMORY; | ||
} | ||
|
||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetInstallationVersion( | ||
_Out_ BSTR* pbstrInstallationVersion | ||
) | ||
{ | ||
if (!pbstrInstallationVersion) | ||
{ | ||
return E_POINTER; | ||
} | ||
|
||
*pbstrInstallationVersion = ::SysAllocString(m_version.c_str()); | ||
if (!pbstrInstallationVersion) | ||
{ | ||
return E_OUTOFMEMORY; | ||
} | ||
|
||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetDisplayName( | ||
_In_ LCID lcid, | ||
_Out_ BSTR* pbstrDisplayName | ||
) | ||
{ | ||
return NotImplemented(pbstrDisplayName); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::GetDescription( | ||
_In_ LCID lcid, | ||
_Out_ BSTR* pbstrDescription | ||
) | ||
{ | ||
return NotImplemented(pbstrDescription); | ||
} | ||
|
||
STDMETHODIMP LegacyInstance::ResolvePath( | ||
_In_opt_z_ LPCOLESTR pwszRelativePath, | ||
_Out_ BSTR* pbstrAbsolutePath | ||
) | ||
{ | ||
return NotImplemented(pbstrAbsolutePath); | ||
} |
Oops, something went wrong.