build/build.ps1: Added option to skip SDK installation and use it from azure-pipelines.yml
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index c156983..27bad45 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -121,9 +121,10 @@
$properties = @{
backup_files='false';
publish_directory='$(PublishTempDirectory)';
- nuget_package_directory='$(NuGetArtifactDirectory)'
+ nuget_package_directory='$(NuGetArtifactDirectory)';
# Lock the build.bat so it only builds this version in the release distribution
- generateBuildBat=$generateBuildBat
+ generateBuildBat=$generateBuildBat;
+ skipSdkInstallation='true'
}
[string[]]$tasks = 'Pack'
if ($Env:RunTests -ne 'false') {
diff --git a/build/build.ps1 b/build/build.ps1
index 8adfd65..6319ccf 100644
--- a/build/build.ps1
+++ b/build/build.ps1
@@ -28,6 +28,7 @@
[string]$solutionFile = "$base_directory/Lucene.Net.sln"
[string]$sdkPath = "$env:programfiles/dotnet/sdk"
[string]$sdkVersion = "5.0.100"
+ [bool]$skipSdkInstallation = $false
[string]$globalJsonFile = "$base_directory/global.json"
[string]$versionPropsFile = "$base_directory/Version.props"
[string]$build_bat = "$base_directory/build.bat"
@@ -74,19 +75,21 @@
}
task InstallSDK -description "This task makes sure the correct SDK version is installed to build" -ContinueOnError {
- Write-Host "##teamcity[progressMessage 'Installing SDK $sdkVersion']"
- Write-Host "##vso[task.setprogress]'Installing SDK $sdkVersion'"
- $installed = Is-Sdk-Version-Installed $sdkVersion
- if (!$installed) {
- Write-Host "Requires SDK version $sdkVersion, installing..." -ForegroundColor Red
- Invoke-Expression "$base_directory\build\dotnet-install.ps1 -Version $sdkVersion"
- }
+ if (!$skipSdkInstallation) {
+ Write-Host "##teamcity[progressMessage 'Installing SDK $sdkVersion']"
+ Write-Host "##vso[task.setprogress]'Installing SDK $sdkVersion'"
+ $installed = Is-Sdk-Version-Installed $sdkVersion
+ if (!$installed) {
+ Write-Host "Requires SDK version $sdkVersion, installing..." -ForegroundColor Red
+ Invoke-Expression "$base_directory\build\dotnet-install.ps1 -Version $sdkVersion"
+ }
- # Safety check - this should never happen
- & where.exe dotnet.exe
+ # Safety check - this should never happen
+ & where.exe dotnet.exe
- if ($LASTEXITCODE -ne 0) {
- throw "Could not find dotnet CLI in PATH. Please install the .NET Core 3.1 SDK, version $sdkVersion."
+ if ($LASTEXITCODE -ne 0) {
+ throw "Could not find dotnet CLI in PATH. Please install the .NET SDK, version $sdkVersion."
+ }
}
}