1
1
param (
2
2
[ValidateSet (" Debug" , " Release" )]
3
- $Configuration = " Debug"
3
+ [ string ] $Configuration = " Debug"
4
4
)
5
5
6
6
# Requires -Modules @ {ModuleName = " InvokeBuild" ;ModuleVersion = " 3.2.1" }
7
7
8
- if ($env: APPVEYOR -ne $null ) {
9
- dotnet -- info
10
- }
8
+ $script :IsCIBuild = $env: APPVEYOR -ne $null
11
9
12
10
task SetupDotNet - Before Restore, Clean , Build, BuildHost, Test, TestPowerShellApi {
13
11
@@ -67,6 +65,25 @@ task Restore {
67
65
68
66
task Clean {
69
67
exec { & dotnet clean }
68
+ Get-ChildItem - Recurse src\* .nupkg | Remove-Item - Force - ErrorAction Ignore
69
+ Get-ChildItem module\* .zip | Remove-Item - Force - ErrorAction Ignore
70
+ }
71
+
72
+ task GetProductVersion - Before PackageNuGet, PackageModule, UploadArtifacts {
73
+ if ($script :BaseVersion ) { return }
74
+ [xml ]$props = Get-Content .\PowerShellEditorServices.Common.props
75
+
76
+ $script :VersionSuffix = $props.Project.PropertyGroup.VersionSuffix
77
+ $script :BaseVersion = " $ ( $props.Project.PropertyGroup.VersionPrefix ) -$ ( $props.Project.PropertyGroup.VersionSuffix ) "
78
+ $script :FullVersion = " $ ( $props.Project.PropertyGroup.VersionPrefix ) -$ ( $props.Project.PropertyGroup.VersionSuffix ) "
79
+
80
+ if ($env: APPVEYOR ) {
81
+ $script :BuildNumber = $env: APPVEYOR_BUILD_NUMBER
82
+ $script :FullVersion = " $script :FullVersion -$script :BuildNumber "
83
+ $script :VersionSuffix = " $script :VersionSuffix -$script :BuildNumber "
84
+ }
85
+
86
+ Write-Host " `n ### Product Version: $script :FullVersion `n " - ForegroundColor Green
70
87
}
71
88
72
89
function BuildForPowerShellVersion ($version ) {
@@ -87,7 +104,6 @@ task TestPowerShellApi {
87
104
}
88
105
89
106
task BuildHost {
90
- # This task is meant to be used in a quick dev cycle so no 'restore' is done first
91
107
exec { & dotnet build - c $Configuration .\src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj }
92
108
}
93
109
@@ -116,5 +132,29 @@ task LayoutModule -After Build, BuildHost {
116
132
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices.Host\bin\$Configuration \netstandard1.6 \* - Filter Microsoft.PowerShell.EditorServices* .dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Core\
117
133
}
118
134
135
+ task PackageNuGet {
136
+ exec { & dotnet pack - c $Configuration -- no- build -- version- suffix $script :VersionSuffix .\src\PowerShellEditorServices\PowerShellEditorServices.csproj }
137
+ exec { & dotnet pack - c $Configuration -- no- build -- version- suffix $script :VersionSuffix .\src\PowerShellEditorServices.Protocol\PowerShellEditorServices.Protocol.csproj }
138
+ exec { & dotnet pack - c $Configuration -- no- build -- version- suffix $script :VersionSuffix .\src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj }
139
+ }
140
+
141
+ task PackageModule {
142
+ Add-Type - Assembly System.IO.Compression.FileSystem
143
+ [System.IO.Compression.ZipFile ]::CreateFromDirectory(
144
+ " $PSScriptRoot /module/PowerShellEditorServices" ,
145
+ " $PSScriptRoot /module/PowerShellEditorServices-$ ( $script :FullVersion ) .zip" ,
146
+ [System.IO.Compression.CompressionLevel ]::Optimal,
147
+ $true )
148
+ }
149
+
150
+ task UploadArtifacts - If ($script :IsCIBuild ) {
151
+ if ($env: APPVEYOR ) {
152
+ Push-AppveyorArtifact .\src\PowerShellEditorServices\bin\$Configuration \Microsoft.PowerShell.EditorServices.$ ($script :FullVersion ).nupkg
153
+ Push-AppveyorArtifact .\src\PowerShellEditorServices.Protocol\bin\$Configuration \Microsoft.PowerShell.EditorServices.Protocol.$ ($script :FullVersion ).nupkg
154
+ Push-AppveyorArtifact .\src\PowerShellEditorServices.Host\bin\$Configuration \Microsoft.PowerShell.EditorServices.Host.$ ($script :FullVersion ).nupkg
155
+ Push-AppveyorArtifact .\module\PowerShellEditorServices- $ ($script :FullVersion ).zip
156
+ }
157
+ }
158
+
119
159
# The default task is to run the entire CI build
120
- task . Restore, Clean , Build, TestPowerShellApi, Test
160
+ task . GetProductVersion , Restore, Clean , Build, TestPowerShellApi, Test, PackageNuGet , PackageModule , UploadArtifacts
0 commit comments