|
|
@@ -6,7 +6,8 @@
|
|
|
[CmdletBinding()]
|
|
|
param(
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
- $BuildXml
|
|
|
+ $BuildXml,
|
|
|
+ [string[]]$ConfigVars = @()
|
|
|
)
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
@@ -19,12 +20,12 @@ $depsPath = Resolve-Path "$PSScriptRoot/../build/dependencies.props"
|
|
|
if ($BuildXml -like 'http*') {
|
|
|
$url = $BuildXml
|
|
|
New-Item -Type Directory "$PSScriptRoot/../obj/" -ErrorAction Ignore
|
|
|
- $BuildXml = "$PSScriptRoot/../obj/build.xml"
|
|
|
+ $localXml = "$PSScriptRoot/../obj/build.xml"
|
|
|
Write-Verbose "Downloading from $url to $BuildXml"
|
|
|
- Invoke-WebRequest -OutFile $BuildXml $url
|
|
|
+ Invoke-WebRequest -OutFile $localXml $url
|
|
|
}
|
|
|
|
|
|
-[xml] $remoteDeps = LoadXml $BuildXml
|
|
|
+[xml] $remoteDeps = LoadXml $localXml
|
|
|
$count = 0
|
|
|
|
|
|
$variables = @{}
|
|
|
@@ -36,15 +37,20 @@ foreach ($package in $remoteDeps.SelectNodes('//Package')) {
|
|
|
Write-Verbose "Found {id: $packageId, version: $packageVersion, varName: $varName }"
|
|
|
|
|
|
if ($variables[$varName]) {
|
|
|
- $variables[$varName] += $packageVersion
|
|
|
- } else {
|
|
|
+ if ($variables[$varName].Where( {$_ -eq $packageVersion}, 'First').Count -eq 0) {
|
|
|
+ $variables[$varName] += $packageVersion
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
$variables[$varName] = @($packageVersion)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+$updatedVars = @{}
|
|
|
+
|
|
|
foreach ($varName in ($variables.Keys | sort)) {
|
|
|
$packageVersions = $variables[$varName]
|
|
|
- if ($packageVersions.Length -gt 1){
|
|
|
+ if ($packageVersions.Length -gt 1) {
|
|
|
Write-Warning "Skipped $varName. Multiple version found. { $($packageVersions -join ', ') }."
|
|
|
continue
|
|
|
}
|
|
|
@@ -56,12 +62,33 @@ foreach ($varName in ($variables.Keys | sort)) {
|
|
|
$depVarNode.InnerText = $packageVersion
|
|
|
$count++
|
|
|
Write-Host -f DarkGray " Updating $varName to $packageVersion"
|
|
|
+ $updatedVars[$varName] = $packageVersion
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ($count -gt 0) {
|
|
|
Write-Host -f Cyan "Updating $count version variables in $depsPath"
|
|
|
SaveXml $dependencies $depsPath
|
|
|
+
|
|
|
+ # Ensure dotnet is installed
|
|
|
+ & "$PSScriptRoot\..\run.ps1" install-tools
|
|
|
+
|
|
|
+ $ProjectPath = "$PSScriptRoot\update-dependencies\update-dependencies.csproj"
|
|
|
+
|
|
|
+ $ConfigVars += "--BuildXml"
|
|
|
+ $ConfigVars += $BuildXml
|
|
|
+
|
|
|
+ $ConfigVars += "--UpdatedVersions"
|
|
|
+ $varString = ""
|
|
|
+ foreach ($updatedVar in $updatedVars.GetEnumerator()) {
|
|
|
+ $varString += "$($updatedVar.Name)=$($updatedVar.Value);"
|
|
|
+ }
|
|
|
+ $ConfigVars += $varString
|
|
|
+
|
|
|
+ # Restore and run the app
|
|
|
+ Write-Host "Invoking App $ProjectPath..."
|
|
|
+ Invoke-Expression "dotnet run -p `"$ProjectPath`" @ConfigVars"
|
|
|
+ if ($LASTEXITCODE -ne 0) { throw "Build failed" }
|
|
|
}
|
|
|
else {
|
|
|
Write-Host -f Green "No changes found"
|