-
Notifications
You must be signed in to change notification settings - Fork 234
Log build info #772
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
Log build info #772
Changes from 3 commits
f1fa0f2
e8979ad
66b3104
a8f26d9
d02ab61
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ $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") | ||
$script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Host", "BuildInfo", "BuildInfo.cs") | ||
|
||
if ($PSVersionTable.PSEdition -ne "Core") { | ||
Add-Type -Assembly System.IO.Compression.FileSystem | ||
|
@@ -142,6 +143,51 @@ task TestPowerShellApi -If { !$script:IsUnix } { | |
exec { & $script:dotnetExe restore .\src\PowerShellEditorServices\PowerShellEditorServices.csproj } | ||
} | ||
|
||
task CreateBuildInfo -Before Build { | ||
$buildVersion = "<development-build>" | ||
$buildOrigin = "<development>" | ||
|
||
# Set build info fields on build platforms | ||
if ($env:APPVEYOR) | ||
{ | ||
$buildVersion = $env:APPVEYOR_BUILD_VERSION | ||
$buildOrigin = if ($env:CI) { "AppVeyor CI" } else { "AppVeyor" } | ||
} | ||
elseif ($env:VSTS_BUILD) | ||
{ | ||
$psd1Path = [System.IO.Path]::Combine($PSScriptRoot, "module", "PowerShellEditorServices", "PowerShellEditorServices.psd1") | ||
$buildVersion = (Import-PowerShellDataFile -LiteralPath $psd1Path).Version | ||
$buildOrigin = "VSTS" | ||
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. Ehhem "Azure Pipelines" 😊 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. I thought about it, but felt we should keep things consistent and change it over all at once. |
||
} | ||
|
||
# Allow override of build info fields (except date) | ||
if ($env:PSES_BUILD_VERSION) | ||
{ | ||
$buildVersion = $env:PSES_BUILD_VERSION | ||
} | ||
|
||
if ($env:PSES_BUILD_ORIGIN) | ||
{ | ||
$buildOrigin = $env:PSES_BUILD_ORIGIN | ||
} | ||
|
||
[string]$buildTime = [datetime]::Now.ToString("s", [System.Globalization.CultureInfo]::InvariantCulture) | ||
|
||
$buildInfoContents = @" | ||
namespace Microsoft.PowerShell.EditorServices.Host | ||
{ | ||
public static class BuildInfo | ||
{ | ||
public const string BuildVersion = "$buildVersion"; | ||
public const string BuildOrigin = "$buildOrigin"; | ||
public static readonly System.DateTime? BuildTime = System.DateTime.Parse("$buildTime"); | ||
} | ||
} | ||
"@ | ||
|
||
Set-Content -LiteralPath $script:BuildInfoPath -Value $buildInfoContents -Force | ||
} | ||
|
||
task Build { | ||
exec { & $script:dotnetExe publish -c $Configuration .\src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj -f netstandard1.6 } | ||
if (!$script:IsUnix) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Microsoft.PowerShell.EditorServices.Host | ||
{ | ||
public static class BuildInfo | ||
{ | ||
public const string BuildVersion = "<unset>"; | ||
public const string BuildOrigin = "<unset>"; | ||
public static readonly System.DateTime? BuildTime = null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
<PackageReference Include="Microsoft.PowerShell.SDK"> | ||
<Version>6.0.0-alpha13</Version> | ||
</PackageReference> | ||
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0" /> | ||
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" /> | ||
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. Now that we are shipping this, I think there were a couple instances where we did some ifdefs between Core and Framework (which didn't have this package). If it's easy, can you remove the ifdefs 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. Also don't forget to register the open source usage. |
||
</ItemGroup> | ||
|
||
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' "> | ||
|
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.
Last I checked the VSTS environment variable that's set is
TF_BUILD
. Do they also setVSTS_BUILD
?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.
We define
VSTS_BUILD
.But I just saw that
TF_BUILD
is defined as well. So probably a good opportunity to removeVSTS_BUILD
.