|
| 1 | +<# |
| 2 | +This is a multi-line comment syntax |
| 3 | +#> |
| 4 | + |
| 5 | +#Requires -Version 6 |
| 6 | + |
| 7 | +Param( |
| 8 | + [string] $NuGetFullPath, |
| 9 | + [string] $connectorPackageVersion = "1.0.0", |
| 10 | + [string] $showCommands = "false", |
| 11 | + [string] $projDir = $(Get-Location), |
| 12 | + [string] $logFile = $(Join-Path $PSScriptRoot .. "deploy_log.txt" -Resolve) |
| 13 | +) |
| 14 | + |
| 15 | +# Reset log file |
| 16 | +if (Test-Path $logFile) { |
| 17 | + Clear-Content $logFile -Force | Out-Null |
| 18 | +} |
| 19 | +else { |
| 20 | + New-Item -Path $logFile | Out-Null |
| 21 | +} |
| 22 | + |
| 23 | +# Check for AZ CLI and confirm version |
| 24 | +if (Get-Command az -ErrorAction SilentlyContinue) { |
| 25 | + $azcliversionoutput = az -v |
| 26 | + [regex]$regex = '(\d{1,3}.\d{1,3}.\d{1,3})' |
| 27 | + [version]$azcliversion = $regex.Match($azcliversionoutput[0]).value |
| 28 | + [version]$minversion = '2.2.0' |
| 29 | + |
| 30 | + if ($azcliversion -ge $minversion) { |
| 31 | + $azclipassmessage = "AZ CLI passes minimum version. Current version is $azcliversion" |
| 32 | + Write-Debug $azclipassmessage |
| 33 | + $azclipassmessage | Out-File -Append -FilePath $logfile |
| 34 | + } |
| 35 | + else { |
| 36 | + $azcliwarnmessage = "You are using an older version of the AZ CLI, ` |
| 37 | + please ensure you are using version $minversion or newer. ` |
| 38 | + The most recent version can be found here: http://aka.ms/installazurecliwindows" |
| 39 | + Write-Warning $azcliwarnmessage |
| 40 | + $azcliwarnmessage | Out-File -Append -FilePath $logfile |
| 41 | + } |
| 42 | +} |
| 43 | +else { |
| 44 | + $azclierrormessage = 'AZ CLI not found. Please install latest version.' |
| 45 | + Write-Error $azclierrormessage |
| 46 | + $azclierrormessage | Out-File -Append -FilePath $logfile |
| 47 | +} |
| 48 | + |
| 49 | +if (-not (Test-Path (Join-Path $projDir 'ACSAgentHub.sln' -Resolve))) |
| 50 | +{ |
| 51 | + Write-Host "! Could not find the 'ACSAgentHub.sln' file in the current directory." -ForegroundColor Red |
| 52 | + Write-Host "+ Please re-run this script from root of the solution directory." -ForegroundColor Magenta |
| 53 | + Break |
| 54 | +} |
| 55 | + |
| 56 | +# Get mandatory parameters |
| 57 | + |
| 58 | +if (-not $NuGetFullPath) { |
| 59 | + $NuGetFullPath = Read-Host "? Full path to nuget.exe (e.g., c:\nuget\nuget.exe):" |
| 60 | +} |
| 61 | + |
| 62 | +if (-not $connectorPackageVersion) { |
| 63 | + $connectorPackageVersion = Read-Host "? Package version (e.g., 1.0.0):" |
| 64 | +} |
| 65 | + |
| 66 | +if (-not $NuGetFullPath) { |
| 67 | + $NuGetFullPath = Read-Host "? Full path to nuget.exe" |
| 68 | +} |
| 69 | + |
| 70 | +# Get timestamp |
| 71 | +$startTime = Get-Date |
| 72 | + |
| 73 | +# Create local NuGet feed for ACSConnector |
| 74 | +Write-Host "Creating local NuGet feed for ACSConnector" -NoNewline -ForegroundColor Green |
| 75 | +$acsConnectorNuGetPackage = Join-Path $PSScriptRoot ..\..\ "ACSConnector\bin\Debug\ACSConnector.$connectorPackageVersion.nupkg" -Resolve |
| 76 | +$acsAgentHubSDKNuGetPackage = Join-Path $PSScriptRoot ..\.. "ACSAgentHubSDK\bin\Debug\ACSAgentHubSDK.$connectorPackageVersion.nupkg" -Resolve |
| 77 | +$acsConnectorLocalFeedFolder = join-Path $PSScriptRoot ..\..\ "ACSConnector\localFeed" -Resolve |
| 78 | +# First, create folder for local NuGet feed |
| 79 | +if ($showCommands.ToLower() -eq "true") {Write-Host ''; Write-Host "mkdir -Force $acsConnectorLocalFeedFolder"} |
| 80 | +mkdir -Force $acsConnectorLocalFeedFolder |
| 81 | + |
| 82 | +if ($showCommands.ToLower() -eq "true") {Write-Host ''; Write-Host "$NuGetFullPath delete ACSAgentHubSDK $connectorPackageVersion -Source $acsConnectorLocalFeedFolder -NonInteractive " } |
| 83 | +& $NuGetFullPath delete ACSAgentHubSDK $connectorPackageVersion -Source $acsConnectorLocalFeedFolder -NonInteractive |
| 84 | +if ($showCommands.ToLower() -eq "true") {Write-Host ''; Write-Host "$NuGetFullPath delete ACSConnector $connectorPackageVersion -Source $acsConnectorLocalFeedFolder -NonInteractive " } |
| 85 | +& $NuGetFullPath delete ACSConnector $connectorPackageVersion -Source $acsConnectorLocalFeedFolder -NonInteractive |
| 86 | + |
| 87 | +# Next, clear all NuGet caches in case we are overwriting existing versions of existing NuGet packages (this can cause runtime startup issues in Composer) |
| 88 | +if ($showCommands.ToLower() -eq "true") {Write-Host ''; Write-Host "$NuGetFullPath locals all -clear" } |
| 89 | +& $NuGetFullPath locals all -clear |
| 90 | + |
| 91 | +# Next, add ACSConnector and its dependencies to local NuGet feed |
| 92 | +if ($showCommands.ToLower() -eq "true") {Write-Host ''; Write-Host "$NuGetFullPath add $acsAgentHubSDKNuGetPackage -Source $acsConnectorLocalFeedFolder" } |
| 93 | +& $NuGetFullPath add $acsAgentHubSDKNuGetPackage -Source $acsConnectorLocalFeedFolder |
| 94 | +if ($showCommands.ToLower() -eq "true") {Write-Host ''; Write-Host "$NuGetFullPath add $acsConnectorNuGetPackage -Source $acsConnectorLocalFeedFolder" } |
| 95 | +& $NuGetFullPath add $acsConnectorNuGetPackage -Source $acsConnectorLocalFeedFolder |
0 commit comments