|
5 | 5 |
|
6 | 6 | param(
|
7 | 7 | [ValidateSet("Debug", "Release")]
|
8 |
| - [string]$Configuration = "Debug" |
| 8 | + [string]$Configuration = "Debug", |
| 9 | + |
| 10 | + [string]$PsesSubmodulePath = "$PSScriptRoot/module", |
| 11 | + |
| 12 | + [string]$ModulesJsonPath = "$PSScriptRoot/modules.json", |
| 13 | + |
| 14 | + [string]$DefaultModuleRepository = "PSGallery" |
9 | 15 | )
|
10 | 16 |
|
11 | 17 | #Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}
|
12 | 18 |
|
13 | 19 | $script:IsCIBuild = $env:APPVEYOR -ne $null
|
14 | 20 | $script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows
|
15 | 21 | $script:TargetFrameworksParam = "/p:TargetFrameworks=\`"$(if (!$script:IsUnix) { "net451;" })netstandard1.6\`""
|
| 22 | +$script:SaveModuleSupportsAllowPrerelease = (Get-Command Save-Module).Parameters.ContainsKey("AllowPrerelease") |
16 | 23 |
|
17 | 24 | if ($PSVersionTable.PSEdition -ne "Core") {
|
18 | 25 | Add-Type -Assembly System.IO.Compression.FileSystem
|
@@ -179,7 +186,7 @@ task TestProtocol -If { !$script:IsUnix} {
|
179 | 186 | task TestHost -If { !$script:IsUnix} {
|
180 | 187 | Set-Location .\test\PowerShellEditorServices.Test.Host\
|
181 | 188 | exec { & $script:dotnetExe build -c $Configuration -f net452 }
|
182 |
| - exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild -x86 } |
| 189 | + exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild } |
183 | 190 | }
|
184 | 191 |
|
185 | 192 | task CITest ?Test, {
|
@@ -220,6 +227,67 @@ task LayoutModule -After Build {
|
220 | 227 | }
|
221 | 228 | }
|
222 | 229 |
|
| 230 | +task RestorePsesModules -After Build { |
| 231 | + $submodulePath = (Resolve-Path $PsesSubmodulePath).Path + [IO.Path]::DirectorySeparatorChar |
| 232 | + Write-Host "`nRestoring EditorServices modules..." |
| 233 | + |
| 234 | + # Read in the modules.json file as a hashtable so it can be splatted |
| 235 | + $moduleInfos = @{} |
| 236 | + |
| 237 | + (Get-Content -Raw $ModulesJsonPath | ConvertFrom-Json).PSObject.Properties | ForEach-Object { |
| 238 | + $name = $_.Name |
| 239 | + $body = @{ |
| 240 | + Name = $name |
| 241 | + MinimumVersion = $_.Value.MinimumVersion |
| 242 | + MaximumVersion = $_.Value.MaximumVersion |
| 243 | + Repository = if ($_.Value.Repository) { $_.Value.Repository } else { $DefaultModuleRepository } |
| 244 | + Path = $submodulePath |
| 245 | + } |
| 246 | + |
| 247 | + if (-not $name) |
| 248 | + { |
| 249 | + throw "EditorServices module listed without name in '$ModulesJsonPath'" |
| 250 | + } |
| 251 | + |
| 252 | + if ($script:SaveModuleSupportsAllowPrerelease) |
| 253 | + { |
| 254 | + $body += @{ AllowPrerelease = $_.Value.AllowPrerelease } |
| 255 | + } |
| 256 | + |
| 257 | + $moduleInfos.Add($name, $body) |
| 258 | + } |
| 259 | + |
| 260 | + # Save each module in the modules.json file |
| 261 | + foreach ($moduleName in $moduleInfos.Keys) |
| 262 | + { |
| 263 | + if (Test-Path -Path (Join-Path -Path $submodulePath -ChildPath $moduleName)) |
| 264 | + { |
| 265 | + Write-Host "`tModule '${moduleName}' already detected. Skipping" |
| 266 | + continue |
| 267 | + } |
| 268 | + |
| 269 | + $moduleInstallDetails = $moduleInfos[$moduleName] |
| 270 | + |
| 271 | + $splatParameters = @{ |
| 272 | + Name = $moduleName |
| 273 | + MinimumVersion = $moduleInstallDetails.MinimumVersion |
| 274 | + MaximumVersion = $moduleInstallDetails.MaximumVersion |
| 275 | + Repository = if ($moduleInstallDetails.Repository) { $moduleInstallDetails.Repository } else { $DefaultModuleRepository } |
| 276 | + Path = $submodulePath |
| 277 | + } |
| 278 | + |
| 279 | + if ($script:SaveModuleSupportsAllowPrerelease) |
| 280 | + { |
| 281 | + $splatParameters += @{ AllowPrerelease = $moduleInstallDetails.AllowPrerelease } |
| 282 | + } |
| 283 | + |
| 284 | + Write-Host "`tInstalling module: ${moduleName}" |
| 285 | + |
| 286 | + Save-Module @splatParameters |
| 287 | + } |
| 288 | + Write-Host "`n" |
| 289 | +} |
| 290 | + |
223 | 291 | task BuildCmdletHelp {
|
224 | 292 | New-ExternalHelp -Path $PSScriptRoot\module\docs -OutputPath $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US -Force
|
225 | 293 | }
|
|
0 commit comments