Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/System.Management.Automation/help/HelpProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,30 +222,20 @@ internal void ReportHelpFileError(Exception exception, string target, string hel

/// <summary>
/// Each Shell ( minishell ) will have its own path specified by the
/// registry HKLM\software\microsoft\msh\1\ShellIds\&lt;ShellID&gt;\path. Every help
/// provider should search this path for content.
/// application base folder, which should be the same as $pshome
/// </summary>
/// <returns>string representing base directory of the executing shell.</returns>
internal string GetDefaultShellSearchPath()
{
string shellID = this.HelpSystem.ExecutionContext.ShellID;
string returnValue = CommandDiscovery.GetShellPathFromRegistry(shellID);
// Beginning in PowerShell 6.0.0.12, the $pshome is no longer registry specified, we search the application base instead.
string returnValue = Utils.GetApplicationBase(shellID);

if (returnValue == null)
{
// use executing assemblies location in case registry entry not found
returnValue = Path.GetDirectoryName(PsUtils.GetMainModule(System.Diagnostics.Process.GetCurrentProcess()).FileName);
}
else
{
// Get the directory path of the executing shell
returnValue = Path.GetDirectoryName(returnValue);
if (!Directory.Exists(returnValue))
{
// use executing assemblies location in case registry entry not found
returnValue = Path.GetDirectoryName(PsUtils.GetMainModule(System.Diagnostics.Process.GetCurrentProcess()).FileName);
}
}

return returnValue;
}
Expand Down
25 changes: 25 additions & 0 deletions test/powershell/engine/Help/HelpSystem.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,28 @@ Describe "Validate about_help.txt under culture specific folder works" -Tags @('
$help | Should BeExactly "Hello"
}
}

Describe "Get-Help should find help info within help files" -Tags @('CI', 'RequireAdminOnWindows') {
It "Get-Help should find help files under pshome" {
$helpFile = "about_testCase.help.txt"
$culture = (Get-Culture).Name
$helpFolderPath = Join-Path $PSHOME $culture
$helpFilePath = Join-Path $helpFolderPath $helpFile

if (!(Test-Path $helpFolderPath))
{
$null = New-Item -ItemType Directory -Path $helpFolderPath -ErrorAction SilentlyContinue
}

try
{
$null = New-Item -ItemType File -Path $helpFilePath -Value "about_test" -ErrorAction SilentlyContinue
$helpContent = Get-Help about_testCase
$helpContent | Should Match "about_test"
}
finally
{
Remove-Item $helpFilePath -Force -ErrorAction SilentlyContinue
}
}
}