|
|
@@ -48,6 +48,9 @@
|
|
|
# True to use global NuGet cache instead of restoring packages to repository-local directory.
|
|
|
[bool]$useGlobalNuGetCache = if (Test-Path variable:useGlobalNuGetCache) { $useGlobalNuGetCache } else { !$ci }
|
|
|
|
|
|
+# True to exclude prerelease versions Visual Studio during build
|
|
|
+[bool]$excludePrereleaseVS = if (Test-Path variable:excludePrereleaseVS) { $excludePrereleaseVS } else { $false }
|
|
|
+
|
|
|
# An array of names of processes to stop on script exit if prepareMachine is true.
|
|
|
$processesToStopOnExit = if (Test-Path variable:processesToStopOnExit) { $processesToStopOnExit } else { @('msbuild', 'dotnet', 'vbcscompiler') }
|
|
|
|
|
|
@@ -463,7 +466,11 @@ function LocateVisualStudio([object]$vsRequirements = $null){
|
|
|
}
|
|
|
|
|
|
if (!$vsRequirements) { $vsRequirements = $GlobalJson.tools.vs }
|
|
|
- $args = @('-latest', '-prerelease', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*')
|
|
|
+ $args = @('-latest', '-format', 'json', '-requires', 'Microsoft.Component.MSBuild', '-products', '*')
|
|
|
+
|
|
|
+ if (!$excludePrereleaseVS) {
|
|
|
+ $args += '-prerelease'
|
|
|
+ }
|
|
|
|
|
|
if (Get-Member -InputObject $vsRequirements -Name 'version') {
|
|
|
$args += '-version'
|
|
|
@@ -489,7 +496,13 @@ function LocateVisualStudio([object]$vsRequirements = $null){
|
|
|
|
|
|
function InitializeBuildTool() {
|
|
|
if (Test-Path variable:global:_BuildTool) {
|
|
|
- return $global:_BuildTool
|
|
|
+ # If the requested msbuild parameters do not match, clear the cached variables.
|
|
|
+ if($global:_BuildTool.Contains('ExcludePrereleaseVS') -and $global:_BuildTool.ExcludePrereleaseVS -ne $excludePrereleaseVS) {
|
|
|
+ Remove-Item variable:global:_BuildTool
|
|
|
+ Remove-Item variable:global:_MSBuildExe
|
|
|
+ } else {
|
|
|
+ return $global:_BuildTool
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (-not $msbuildEngine) {
|
|
|
@@ -517,7 +530,7 @@ function InitializeBuildTool() {
|
|
|
ExitWithExitCode 1
|
|
|
}
|
|
|
|
|
|
- $buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "net472" }
|
|
|
+ $buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "net472"; ExcludePrereleaseVS = $excludePrereleaseVS }
|
|
|
} else {
|
|
|
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unexpected value of -msbuildEngine: '$msbuildEngine'."
|
|
|
ExitWithExitCode 1
|