Use a simple file based check for the VC++ 2015 redistributables (#4745)

* A simple and minimal fix of 4665 to check for the Visual Studio C++ 2015 redistributables. Note that this is specific to 2015 (vcruntime140.dll refers to the Visual Studio version 14.0, which maps to Visual Studio 2015).
A previous check registry check of 'SOFTWARE\Microsoft\DevDiv\VC\Servicing\14.0\RuntimeMinimum' failed because when the redistributables are installed via Windows update (which does not use MSI), then the registry entry did not get populated.
The 'Pending' attribute was removed from existing tests since the download links are now present again and the tests were improved using Pester TestCases.

* Fixed typo spotted in code review of PR 4745

* Remove DirectorySearch Id duplication by defining it once and referencing according to this special trick in the official WiX documentation here: http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/directorysearchref.html
Renamed property values as suggested.

* Remove replacements of HTTPS with HTTP, i.e. test against exact link. Use -UseBasicParsing switch with the hope of not having failures in the CI environment.
Added comment why there is no assertion about the StatusCode.

* Replace download links with link to pre-requisites page as suggested in PR 4745 because this page is easier to update

* Compilation error CNDL0012 fix: WiX does not allow lowercase characters for file search property Ids because due to them being used for a search property means that they must be public, hence lowercase is not allowed.
This commit is contained in:
bergmeister 2017-09-15 02:42:36 +01:00 committed by Mike Richmond
parent a4cdb806f4
commit da49841f16
2 changed files with 28 additions and 25 deletions

View file

@ -60,15 +60,27 @@
<!--We need to show EULA, and provide option to customize download location-->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<!-- Prerequisites check for Windows Universal C time and Visual Studio 2015 C++ redistributables -->
<Property Id="UCRTINSTALLED" Secure="yes">
<DirectorySearch Id="Windows_System32" Path="[WindowsFolder]System32" Depth="0">
<FileSearch Name="ucrtbase.dll"/>
<!-- Prerequisite check for Windows Universal C runtime -->
<Property Id="UNIVERSAL_C_RUNTIME_INSTALLED" Secure="yes">
<DirectorySearch Id="WindowsDirectory" Path="[WindowsFolder]">
<DirectorySearch Id="System32" Path="System32">
<FileSearch Id="ucrtbase" Name="ucrtbase.dll"/>
</DirectorySearch>
</DirectorySearch>
</Property>
<Condition Message="$(env.ProductName) requires the Universal C Runtime to be installed. You can download it here: https://www.microsoft.com/download/details.aspx?id=50410">
<![CDATA[Installed OR UCRTINSTALLED]]>
<Condition Message="$(env.ProductName) requires the Universal C Runtime to be installed. You can find a download link to it here: https://github.com/PowerShell/PowerShell/blob/master/docs/installation/windows.md#prerequisites">
<![CDATA[Installed OR UNIVERSAL_C_RUNTIME_INSTALLED]]>
</Condition>
<!-- Prerequisite check for Visual Studio 2015 C++ redistributables -->
<Property Id="VISUAL_CPP_RUNTIME_INSTALLED" Secure="yes">
<DirectorySearchRef Id="System32" Parent="WindowsDirectory" Path="System32">
<FileSearch Id="vcruntime140" Name="vcruntime140.dll"/>
</DirectorySearchRef>
</Property>
<Condition Message="$(env.ProductName) requires the Visual Studio 2015 C++ redistributables to be installed. You can find a download link to it here: https://github.com/PowerShell/PowerShell/blob/master/docs/installation/windows.md#prerequisites">
<![CDATA[Installed OR VISUAL_CPP_RUNTIME_INSTALLED]]>
</Condition>
<Directory Id="TARGETDIR" Name="SourceDir">

View file

@ -14,24 +14,15 @@ Describe "Windows Installer" -Tags "Scenario" {
$global:PSDefaultParameterValues = $originalDefaultParameterValues
}
Context "Universal C Runtime Download Link" {
$universalCRuntimeDownloadLink = 'https://www.microsoft.com/download/details.aspx?id=50410'
It "Wix file should have download link about Universal C runtime" -Pending {
(Get-Content $wixProductFile -Raw).Contains($universalCRuntimeDownloadLink) | Should Be $true
}
It "Should have download link about Universal C runtime that is reachable" {
(Invoke-WebRequest $universalCRuntimeDownloadLink.Replace("https://",'http://')) | Should Not Be $null
}
$preRequisitesLink = 'https://github.com/PowerShell/PowerShell/blob/master/docs/installation/windows.md#prerequisites'
It "WiX (Windows Installer XML) file contains pre-requisites link $preRequisitesLink" {
(Get-Content $wixProductFile -Raw).Contains($preRequisitesLink) | Should Be $true
}
Context "Visual Studio C++ Redistributables Link" {
$visualStudioCPlusPlusRedistributablesDownloadLink = 'https://www.microsoft.com/download/details.aspx?id=48145'
It "WiX file should have documentation about Visual Studio C++ redistributables" -Pending {
(Get-Content $wixProductFile -Raw).Contains($visualStudioCPlusPlusRedistributablesDownloadLink) | Should Be $true
}
It "Should have download link about Universal C runtime that is reachable" {
(Invoke-WebRequest $visualStudioCPlusPlusRedistributablesDownloadLink.Replace("https://",'http://')) | Should Not Be $null
}
It "Pre-Requisistes link $preRequisitesLink is reachable" -TestCases $downloadLinks -Test {
# Because an outdated link 'https://www.microsoft.com/download/details.aspx?id=504100000' would still return a 200 reponse (due to a redirection to an error page), it only checks that it returns something
(Invoke-WebRequest $preRequisitesLink -UseBasicParsing) | Should Not Be $null
}
}
}