Skip to content

Commit

Permalink
Use latest version of VS that is available (#2314)
Browse files Browse the repository at this point in the history
* Use VS2017 or newer

* Add missing pipeline
  • Loading branch information
nohwnd authored Jan 31, 2020
1 parent 064dcc1 commit 1529833
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Param(
# E.g. VS 2017 Update 1 Preview will have version 15.1.1
[Parameter(Mandatory=$false)]
[Alias("v")]
[System.String] $Version = "", # Will set this later by reading TestPlatform.Settings.targets file.
[System.String] $Version, # Will set this later by reading TestPlatform.Settings.targets file.

[Parameter(Mandatory=$false)]
[Alias("vs")]
Expand Down Expand Up @@ -65,8 +65,12 @@ $env:TP_PACKAGE_PROJ_DIR = Join-Path $env:TP_ROOT_DIR "src\package"
# Set Version from scripts/build/TestPlatform.Settings.targets
if([string]::IsNullOrWhiteSpace($Version))
{
$Version = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Settings.targets)).Project.PropertyGroup.TPVersionPrefix
$Version = ($Version).Trim()
$Version = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Settings.targets)).Project.PropertyGroup.TPVersionPrefix |
Where-Object { $_ } |
ForEach-Object { $_.Trim() } |
Select-Object -First 1

Write-Verbose "Version was not provided using version '$Version' from TestPlatform.Settings.targets"
}

#
Expand Down Expand Up @@ -564,12 +568,12 @@ function Create-VsixPackage
Update-VsixVersion $vsixProjectDir

# Build vsix project to get TestPlatform.vsix
Write-Verbose "$msbuildPath\msbuild.exe $vsixProjectDir\TestPlatform.csproj -p:Configuration=$Configuration"
& $msbuildPath\msbuild.exe "$vsixProjectDir\TestPlatform.csproj" -p:Configuration=$Configuration
Write-Verbose "$msbuildPath $vsixProjectDir\TestPlatform.csproj -p:Configuration=$Configuration"
& $msbuildPath "$vsixProjectDir\TestPlatform.csproj" -p:Configuration=$Configuration
}
else
{
Write-Log ".. Create-VsixPackage: Cannot generate vsix as msbuild.exe not found at '$msbuildPath'."
{
throw ".. Create-VsixPackage: Cannot generate vsix as msbuild.exe not found at '$msbuildPath'."
}

Write-Log "Create-VsixPackage: Complete. {$(Get-ElapsedTime($timer))}"
Expand Down Expand Up @@ -769,17 +773,16 @@ function PrintAndExit-OnError([System.String] $output)
function Locate-MSBuildPath
{
$vsInstallPath = Locate-VsInstallPath
$msbuildPath = Get-ChildItem (Join-Path -path $vsInstallPath -childPath "MSBuild\*\Bin\MSBuild.exe")

if([string]::IsNullOrEmpty($vsInstallPath))
{
return $null
Write-Verbose "found msbuild : '$($msbuildPath -join "','")'"
$msBuild = $msBuildPath | Select-Object -First 1
Write-Verbose "msbuildPath is : '$($msbuildPath -join "','")'"
if ($null -eq $msBuild -or 0 -eq $msBuild.Count) {
throw "MSBuild not found."
}

$vsInstallPath = Resolve-Path -path $vsInstallPath
$msbuildPath = Join-Path -path $vsInstallPath -childPath "MSBuild\$env:MSBUILD_VERSION\Bin"

Write-Verbose "msbuildPath is : $msbuildPath"
return $msbuildPath
return $msBuild.FullName
}

function Locate-VsInstallPath
Expand All @@ -796,22 +799,31 @@ function Locate-VsInstallPath

Try
{
Write-Verbose "VSWhere command line: $vswhere -version '(15.0,16.0]' -prerelease -products * -requires $requiredPackageIds -property installationPath"
if ($TPB_CIBuild) {
$vsInstallPath = & $vswhere -version '(15.0,16.0]' -products * -requires $requiredPackageIds -property installationPath
Write-Verbose "VSWhere command line: $vswhere -version '(15.0' -products * -requires $requiredPackageIds -property installationPath"
$vsInstallPath = & $vswhere -version '(15.0' -products * -requires $requiredPackageIds -property installationPath
}
else {
# Allow using pre release versions of VS for dev builds
$vsInstallPath = & $vswhere -version '(15.0,16.0]' -prerelease -products * -requires $requiredPackageIds -property installationPath
Write-Verbose "VSWhere command line: $vswhere -version '(15.0' -prerelease -products * -requires $requiredPackageIds -property installationPath"
$vsInstallPath = & $vswhere -version '(15.0' -prerelease -products * -requires $requiredPackageIds -property installationPath
}
}
Catch [System.Management.Automation.MethodInvocationException]
{
Write-Verbose "Failed to find VS installation with requirements : $requiredPackageIds"
throw "Failed to find VS installation with requirements: $requiredPackageIds"
}

if ($null -eq $vsInstallPath -or 0 -eq @($vsInstallPath).Count) {
throw "Failed to find VS installation with requirements: $requiredPackageIds"
}
else {
Write-Verbose "Found VS installation with requirements '$($requiredPackageIds -join "','")' : '$($vsInstallPath -join "','")'."
}

Write-Verbose "VSInstallPath is : $vsInstallPath"
return $vsInstallPath
$vsPath = $vsInstallPath | Select-Object -First 1
Write-Verbose "VSInstallPath is : $vsPath"
return $vsPath
}

function Update-VsixVersion($vsixProjectDir)
Expand Down

0 comments on commit 1529833

Please sign in to comment.