Skip to content

Commit de1b549

Browse files
committed
Set up build script, VS Code tasks, and AppVeyor configuration
This change establishes an Invoke-Build script for building and testing the project, the VS Code tasks that will launch the build script, and an AppVeyor configuration that can run the build script in a CI build.
1 parent d96ab61 commit de1b549

File tree

6 files changed

+127
-126
lines changed

6 files changed

+127
-126
lines changed

.build.ps1

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
param(
2+
[ValidateSet("Debug", "Release")]
3+
$Configuration = "Debug"
4+
)
5+
6+
#Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.2.1"}
7+
8+
task EnsureDotNet -Before Clean, Build, BuildHost, Test, TestPowerShellApi {
9+
# TODO: Download if it doesn't exist in known paths
10+
if (!(Test-Path 'c:\Program Files\dotnet\dotnet.exe')) {
11+
Write-Error "dotnet is not installed"
12+
}
13+
14+
exec {
15+
if (!((& dotnet --version) -like "*preview4*")) {
16+
Write-Error "You must have at least preview4 of the dotnet tools installed."
17+
}
18+
}
19+
}
20+
21+
task Clean {
22+
exec { & dotnet clean .\PowerShellEditorServices.sln }
23+
}
24+
25+
function BuildForPowerShellVersion($version) {
26+
exec { & dotnet restore .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -- /p:PowerShellVersion=$version }
27+
28+
Write-Host -ForegroundColor Green "`n### Testing API usage for PowerShell $version...`n"
29+
exec { & dotnet build -f net451 .\src\PowerShellEditorServices\PowerShellEditorServices.csproj -- /p:PowerShellVersion=$version}
30+
}
31+
32+
task TestPowerShellApi {
33+
BuildForPowerShellVersion v3
34+
BuildForPowerShellVersion v4
35+
BuildForPowerShellVersion v5r1
36+
BuildForPowerShellVersion v5r2
37+
}
38+
39+
task BuildHost EnsureDotNet, {
40+
# This task is meant to be used in a quick dev cycle so no 'restore' is done first
41+
exec { & dotnet build -c $Configuration .\src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj }
42+
}
43+
44+
task Build {
45+
exec { & dotnet restore -v:m .\PowerShellEditorServices.sln }
46+
exec { & dotnet build -c $Configuration .\PowerShellEditorServices.sln }
47+
}
48+
49+
task Test {
50+
$testParams = @{}
51+
if ($env:APPVEYOR -ne $null) {
52+
$testParams = @{"l" = "appveyor"}
53+
}
54+
55+
exec { & dotnet test -c $Configuration @testParams .\test\PowerShellEditorServices.Test\PowerShellEditorServices.Test.csproj }
56+
exec { & dotnet test -c $Configuration @testParams .\test\PowerShellEditorServices.Test.Protocol\PowerShellEditorServices.Test.Protocol.csproj }
57+
exec { & dotnet test -c $Configuration @testParams .\test\PowerShellEditorServices.Test.Host\PowerShellEditorServices.Test.Host.csproj }
58+
}
59+
60+
task LayoutModule -After Build, BuildHost {
61+
New-Item -Force $PSScriptRoot\module\PowerShellEditorServices\bin\ -Type Directory | Out-Null
62+
New-Item -Force $PSScriptRoot\module\PowerShellEditorServices\bin\Desktop -Type Directory | Out-Null
63+
New-Item -Force $PSScriptRoot\module\PowerShellEditorServices\bin\Core -Type Directory | Out-Null
64+
65+
Copy-Item -Force -Path $PSScriptRoot\src\PowerShellEditorServices.Host\bin\$Configuration\net451\* -Filter Microsoft.PowerShell.EditorServices*.dll -Destination $PSScriptRoot\module\PowerShellEditorServices\bin\Desktop\
66+
Copy-Item -Force -Path $PSScriptRoot\src\PowerShellEditorServices.Host\bin\$Configuration\net451\Newtonsoft.Json.dll -Destination $PSScriptRoot\module\PowerShellEditorServices\bin\Desktop\
67+
Copy-Item -Force -Path $PSScriptRoot\src\PowerShellEditorServices.Host\bin\$Configuration\netstandard1.6\* -Filter Microsoft.PowerShell.EditorServices*.dll -Destination $PSScriptRoot\module\PowerShellEditorServices\bin\Core\
68+
}
69+
70+
task . Clean, Build, Test, TestPowerShellApi

.vscode/tasks.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"version": "0.1.0",
3+
4+
"windows": {
5+
"command": "${env.windir}\\sysnative\\windowspowershell\\v1.0\\PowerShell.exe"
6+
},
7+
"linux": {
8+
"command": "/usr/bin/powershell"
9+
},
10+
"osx": {
11+
"command": "/usr/local/bin/powershell"
12+
},
13+
14+
"isShellCommand": true,
15+
"showOutput": "always",
16+
"args": [ "-NoProfile", "-ExecutionPolicy", "Bypass" ],
17+
18+
// Associate with test task runner
19+
"tasks": [
20+
{
21+
"taskName": "Clean",
22+
"suppressTaskName": true,
23+
"args": [ "Invoke-Build Clean" ]
24+
},
25+
{
26+
"taskName": "Build",
27+
"suppressTaskName": true,
28+
"isBuildCommand": true,
29+
"args": [ "Invoke-Build BuildHost" ]
30+
},
31+
{
32+
"taskName": "Full Build",
33+
"suppressTaskName": true,
34+
"args": [ "Invoke-Build" ]
35+
},
36+
{
37+
"taskName": "Test",
38+
"suppressTaskName": true,
39+
"isTestCommand": true,
40+
"args": [ "Invoke-Build Test" ]
41+
}
42+
]
43+
}

appveyor.yml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,16 @@ branches:
2121
#init:
2222
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
2323

24-
assembly_info:
25-
patch: true
26-
file: '**\AssemblyInfo.*'
27-
assembly_version: '{version}'
28-
assembly_file_version: '{version}'
29-
assembly_informational_version: '$(core_version)$(prerelease_name)+{build}'
24+
# TODO: Work build number into build!
3025

3126
install:
32-
- git submodule -q update --init
33-
34-
before_build:
35-
- ps: if (Test-Path 'C:\Tools\NuGet3') { $nugetDir = 'C:\Tools\NuGet3' } else { $nugetDir = 'C:\Tools\NuGet' }; (New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe', "$nugetDir\NuGet.exe")
36-
- nuget restore PowerShellEditorServices.sln
37-
38-
build:
39-
project: PowerShellEditorServices.NoNano.sln
40-
publish_nuget: true
41-
verbosity: minimal
42-
43-
test:
44-
assemblies:
45-
- Microsoft.PowerShell.EditorServices.Test.dll
46-
- Microsoft.PowerShell.EditorServices.Test.Protocol.dll
47-
- Microsoft.PowerShell.EditorServices.Test.Host.dll
48-
- Microsoft.PowerShell.EditorServices.Test.Channel.WebSockets.dll
27+
- ps: |
28+
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
29+
Install-Module InvokeBuild -RequiredVersion 3.2.1 -Scope CurrentUser -Force | Out-Null
30+
31+
# before_build:
32+
# - ps: if (Test-Path 'C:\Tools\NuGet3') { $nugetDir = 'C:\Tools\NuGet3' } else { $nugetDir = 'C:\Tools\NuGet' }; (New-Object Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe', "$nugetDir\NuGet.exe")
33+
# - nuget restore PowerShellEditorServices.sln
34+
35+
build_script:
36+
- ps: Invoke-Build -Configuration Release

module/PowerShellEditorServices/PowerShellEditorServices.psm1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") {
33
Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.Host.dll"
44
}
55
else {
6-
Add-Type -Path "$PSScriptRoot/bin/Nano/Microsoft.PowerShell.EditorServices.Nano.dll"
6+
Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.dll"
7+
Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Host.dll"
78
}
89

910
function Start-EditorServicesHost {

src/PowerShellEditorServices/PowerShellEditorServices.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.0.0" />
6262
</ItemGroup>
6363

64-
<ItemGroup Condition=" '$(PowerShellVersion)' == '' ">
64+
<ItemGroup Condition=" '$(PowerShellVersion)' == '' Or '$(PowerShellVersion)' == 'v5r2'">
6565
<PackageReference Include="Microsoft.PowerShell.SDK">
6666
<Version>6.0.0-alpha13</Version>
6767
</PackageReference>

test/PowerShellEditorServices.Test/Language/PowerShellVersionTests.cs

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)