From 8583cf5e960d04e369e7ac162eec07be91780cac Mon Sep 17 00:00:00 2001 From: James Truher Date: Thu, 19 May 2016 13:19:16 -0700 Subject: [PATCH] update PSVersionTable code to use powershell.version rather than .version because on Linux the .version file doesn't seem to be binplaced. I postulate this is because it's a hidden file --- .gitignore | 3 +++ build.psm1 | 2 +- src/Microsoft.PowerShell.ConsoleHost/project.json | 2 +- src/System.Management.Automation/engine/PSVersionInfo.cs | 4 ++-- src/powershell/project.json | 3 ++- test/powershell/PSVersionTable.Tests.ps1 | 3 +++ 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 1cd5945326..b354858e8a 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ install.ps1 # We copy powershell.exe as a content in host dotnet cli projects *.exe + +# ignore the version file as it is generated at build time +powershell.version diff --git a/build.psm1 b/build.psm1 index 05ffa606f2..bef63f25b7 100644 --- a/build.psm1 +++ b/build.psm1 @@ -53,7 +53,7 @@ function Start-PSBuild { [string]$msbuildConfiguration = "Release" ) - git describe --dirty --abbrev=60 > "$psscriptroot/.version" + git describe --dirty --abbrev=60 > "$psscriptroot/powershell.version" # simplify ParameterSetNames if ($PSCmdlet.ParameterSetName -eq 'FullCLR') { diff --git a/src/Microsoft.PowerShell.ConsoleHost/project.json b/src/Microsoft.PowerShell.ConsoleHost/project.json index ff14872157..20d094351a 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/project.json +++ b/src/Microsoft.PowerShell.ConsoleHost/project.json @@ -19,7 +19,7 @@ "Modules", "../Modules", "powershell.exe", - "../../.version" + "../../powershell.version" ], "frameworks": { diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 4cbf61fcaa..8d84ac1cea 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -82,12 +82,12 @@ namespace System.Management.Automation return new Version(buildVersion); } - // Get the commit id from the .version file. If the .version file doesn't exist, use the string "N/A" + // Get the commit id from the powershell.version file. If the powershell.version file doesn't exist, use the string "N/A" static internal string GetCommitInfo() { try { string assemblyPath = IO.Path.GetDirectoryName(typeof(PSVersionInfo).GetTypeInfo().Assembly.Location); - return (IO.File.ReadAllLines(IO.Path.Combine(assemblyPath,".version"))[0]); + return (IO.File.ReadAllLines(IO.Path.Combine(assemblyPath,"powershell.version"))[0]); } catch (Exception e){ return e.Message; diff --git a/src/powershell/project.json b/src/powershell/project.json index 08e061986e..2b15474929 100644 --- a/src/powershell/project.json +++ b/src/powershell/project.json @@ -19,7 +19,8 @@ "../Modules", "*_profile.ps1", "*.so", - "*.dylib" + "*.dylib", + "../../powershell.version" ], "frameworks": { diff --git a/test/powershell/PSVersionTable.Tests.ps1 b/test/powershell/PSVersionTable.Tests.ps1 index baef3db530..ea414f1410 100644 --- a/test/powershell/PSVersionTable.Tests.ps1 +++ b/test/powershell/PSVersionTable.Tests.ps1 @@ -15,6 +15,9 @@ Describe "PSVersionTable" { $PSVersionTable.ContainsKey("GitCommitId") | Should Be True } + It "GitCommitId property should not contain an error" { + $PSVersionTable.GitCommitId | Should not match "powershell.version" + } It "Should have the correct edition" -Skip:(!$IsCore) { $expected =