@@ -20,6 +20,7 @@ $script:IsCIBuild = $env:APPVEYOR -ne $null
20
20
$script :IsUnix = $PSVersionTable.PSEdition -and $PSVersionTable.PSEdition -eq " Core" -and ! $IsWindows
21
21
$script :TargetFrameworksParam = " /p:TargetFrameworks=\`" $ ( if (! $script :IsUnix ) { " net451;" }) netstandard1.6\`" "
22
22
$script :SaveModuleSupportsAllowPrerelease = (Get-Command Save-Module ).Parameters.ContainsKey(" AllowPrerelease" )
23
+ $script :BuildInfoPath = [System.IO.Path ]::Combine($PSScriptRoot , " src" , " PowerShellEditorServices.Host" , " BuildInfo" , " BuildInfo.cs" )
23
24
24
25
if ($PSVersionTable.PSEdition -ne " Core" ) {
25
26
Add-Type - Assembly System.IO.Compression.FileSystem
@@ -142,6 +143,51 @@ task TestPowerShellApi -If { !$script:IsUnix } {
142
143
exec { & $script :dotnetExe restore .\src\PowerShellEditorServices\PowerShellEditorServices.csproj }
143
144
}
144
145
146
+ task CreateBuildInfo - Before Build {
147
+ $buildVersion = " <development-build>"
148
+ $buildOrigin = " <development>"
149
+
150
+ # Set build info fields on build platforms
151
+ if ($env: APPVEYOR )
152
+ {
153
+ $buildVersion = $env: APPVEYOR_BUILD_VERSION
154
+ $buildOrigin = if ($env: CI ) { " AppVeyor CI" } else { " AppVeyor" }
155
+ }
156
+ elseif ($env: TF_BUILD )
157
+ {
158
+ $psd1Path = [System.IO.Path ]::Combine($PSScriptRoot , " module" , " PowerShellEditorServices" , " PowerShellEditorServices.psd1" )
159
+ $buildVersion = (Import-PowerShellDataFile - LiteralPath $psd1Path ).Version
160
+ $buildOrigin = " VSTS"
161
+ }
162
+
163
+ # Allow override of build info fields (except date)
164
+ if ($env: PSES_BUILD_VERSION )
165
+ {
166
+ $buildVersion = $env: PSES_BUILD_VERSION
167
+ }
168
+
169
+ if ($env: PSES_BUILD_ORIGIN )
170
+ {
171
+ $buildOrigin = $env: PSES_BUILD_ORIGIN
172
+ }
173
+
174
+ [string ]$buildTime = [datetime ]::Now.ToString(" s" , [System.Globalization.CultureInfo ]::InvariantCulture)
175
+
176
+ $buildInfoContents = @"
177
+ namespace Microsoft.PowerShell.EditorServices.Host
178
+ {
179
+ public static class BuildInfo
180
+ {
181
+ public const string BuildVersion = "$buildVersion ";
182
+ public const string BuildOrigin = "$buildOrigin ";
183
+ public static readonly System.DateTime? BuildTime = System.DateTime.Parse("$buildTime ");
184
+ }
185
+ }
186
+ "@
187
+
188
+ Set-Content - LiteralPath $script :BuildInfoPath - Value $buildInfoContents - Force
189
+ }
190
+
145
191
task Build {
146
192
exec { & $script :dotnetExe publish - c $Configuration .\src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj -f netstandard1.6 }
147
193
if (! $script :IsUnix ) {
@@ -208,6 +254,7 @@ task LayoutModule -After Build {
208
254
New-Item - Force $PSScriptRoot \module\PowerShellEditorServices\bin\Core - Type Directory | Out-Null
209
255
210
256
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices\bin\$Configuration \netstandard1.6 \publish\Serilog* .dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Core\
257
+ Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices\bin\$Configuration \netstandard1.6 \publish\System.Runtime.InteropServices.RuntimeInformation.dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Core\
211
258
212
259
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices.Host\bin\$Configuration \netstandard1.6 \* - Filter Microsoft.PowerShell.EditorServices* .dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Core\
213
260
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices.Host\bin\$Configuration \netstandard1.6 \UnixConsoleEcho.dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Core\
@@ -216,11 +263,11 @@ task LayoutModule -After Build {
216
263
217
264
if (! $script :IsUnix ) {
218
265
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices\bin\$Configuration \net451\Serilog* .dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Desktop
266
+ Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices\bin\$Configuration \net451\System.Runtime.InteropServices.RuntimeInformation.dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Desktop\
219
267
220
268
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices.Host\bin\$Configuration \net451\* - Filter Microsoft.PowerShell.EditorServices* .dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Desktop\
221
269
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices.Host\bin\$Configuration \net451\Newtonsoft.Json.dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Desktop\
222
270
Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices.Host\bin\$Configuration \net451\UnixConsoleEcho.dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Desktop\
223
- Copy-Item - Force - Path $PSScriptRoot \src\PowerShellEditorServices.Host\bin\$Configuration \net451\publish\System.Runtime.InteropServices.RuntimeInformation.dll - Destination $PSScriptRoot \module\PowerShellEditorServices\bin\Desktop\
224
271
}
225
272
226
273
# Copy Third Party Notices.txt to module folder
0 commit comments