-
Notifications
You must be signed in to change notification settings - Fork 236
Change PSES to be buildable as a standalone #647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,21 @@ | |
|
||
param( | ||
[ValidateSet("Debug", "Release")] | ||
[string]$Configuration = "Debug" | ||
[string]$Configuration = "Debug", | ||
|
||
[string]$PsesSubmodulePath = "$PSScriptRoot/module", | ||
|
||
[string]$ModulesJsonPath = "$PSScriptRoot/modules.json", | ||
|
||
[string]$DefaultModuleRepository = "PSGallery" | ||
) | ||
|
||
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"} | ||
|
||
$script:IsCIBuild = $env:APPVEYOR -ne $null | ||
$script:IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq "Core" -and !$IsWindows | ||
$script:TargetFrameworksParam = "/p:TargetFrameworks=\`"$(if (!$script:IsUnix) { "net451;" })netstandard1.6\`"" | ||
$script:SaveModuleSupportsAllowPrerelease = (Get-Command Save-Module).Parameters.ContainsKey("AllowPrerelease") | ||
|
||
if ($PSVersionTable.PSEdition -ne "Core") { | ||
Add-Type -Assembly System.IO.Compression.FileSystem | ||
|
@@ -179,7 +186,7 @@ task TestProtocol -If { !$script:IsUnix} { | |
task TestHost -If { !$script:IsUnix} { | ||
Set-Location .\test\PowerShellEditorServices.Test.Host\ | ||
exec { & $script:dotnetExe build -c $Configuration -f net452 } | ||
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild -x86 } | ||
exec { & $script:dotnetExe xunit -configuration $Configuration -framework net452 -verbose -nobuild } | ||
} | ||
|
||
task CITest ?Test, { | ||
|
@@ -220,6 +227,67 @@ task LayoutModule -After Build { | |
} | ||
} | ||
|
||
task RestorePsesModules -After Build { | ||
$submodulePath = (Resolve-Path $PsesSubmodulePath).Path + [IO.Path]::DirectorySeparatorChar | ||
Write-Host "`nRestoring EditorServices modules..." | ||
|
||
# Read in the modules.json file as a hashtable so it can be splatted | ||
$moduleInfos = @{} | ||
|
||
(Get-Content -Raw $ModulesJsonPath | ConvertFrom-Json).PSObject.Properties | ForEach-Object { | ||
$name = $_.Name | ||
$body = @{ | ||
Name = $name | ||
MinimumVersion = $_.Value.MinimumVersion | ||
MaximumVersion = $_.Value.MaximumVersion | ||
Repository = if ($_.Value.Repository) { $_.Value.Repository } else { $DefaultModuleRepository } | ||
Path = $submodulePath | ||
} | ||
|
||
if (-not $name) | ||
{ | ||
throw "EditorServices module listed without name in '$ModulesJsonPath'" | ||
} | ||
|
||
if ($script:SaveModuleSupportsAllowPrerelease) | ||
{ | ||
$body += @{ AllowPrerelease = $_.Value.AllowPrerelease } | ||
} | ||
|
||
$moduleInfos.Add($name, $body) | ||
} | ||
|
||
# Save each module in the modules.json file | ||
foreach ($moduleName in $moduleInfos.Keys) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have two foreach's one right after the other. Any chance we can combine those? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only problem is that if there's a bad field in the json file, we'll install half the things and then abort. Ideally, we could have an explicit failure line after the first foreach, but I'm not sure what the best way to detect a failure is or what the best way to fail in a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. eh. Not worth implementing. What you have is good :) |
||
{ | ||
if (Test-Path -Path (Join-Path -Path $submodulePath -ChildPath $moduleName)) | ||
{ | ||
Write-Host "`tModule '${moduleName}' already detected. Skipping" | ||
continue | ||
} | ||
|
||
$moduleInstallDetails = $moduleInfos[$moduleName] | ||
|
||
$splatParameters = @{ | ||
Name = $moduleName | ||
MinimumVersion = $moduleInstallDetails.MinimumVersion | ||
MaximumVersion = $moduleInstallDetails.MaximumVersion | ||
Repository = if ($moduleInstallDetails.Repository) { $moduleInstallDetails.Repository } else { $DefaultModuleRepository } | ||
Path = $submodulePath | ||
} | ||
|
||
if ($script:SaveModuleSupportsAllowPrerelease) | ||
{ | ||
$splatParameters += @{ AllowPrerelease = $moduleInstallDetails.AllowPrerelease } | ||
} | ||
|
||
Write-Host "`tInstalling module: ${moduleName}" | ||
|
||
Save-Module @splatParameters | ||
} | ||
Write-Host "`n" | ||
} | ||
|
||
task BuildCmdletHelp { | ||
New-ExternalHelp -Path $PSScriptRoot\module\docs -OutputPath $PSScriptRoot\module\PowerShellEditorServices\Commands\en-US -Force | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"PSScriptAnalyzer":{ | ||
"MinimumVersion":"1.6", | ||
"MaximumVersion":"1.99", | ||
"AllowPrerelease":false | ||
}, | ||
"Plaster":{ | ||
"MinimumVersion":"1.0", | ||
"MaximumVersion":"1.99", | ||
"AllowPrerelease":false | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I have no idea what the consequences of this change could be. Because I'm not sure why that was there originally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect it's because VSCode use to only be 32bit but now it has a 64bit version so we can probably safely remove this.