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
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## PR Summary

<!-- summarize your PR between here and the checklist -->

## PR Checklist
Expand All @@ -12,6 +13,6 @@ Note: Please mark anything not applicable to this PR `NA`.
- [ ] Issue filed - Issue link:
- [ ] [Change is not breaking](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#making-breaking-changes)
- [ ] [Make sure you've added a new test if existing tests do not effectively test the code changed](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#before-submitting)
- [ ] [Add `[feature]` if the change is significant or affectes feature tests](https://github.com/PowerShell/PowerShell/blob/master/docs/testing-guidelines/testing-guidelines.md#requesting-additional-tests-for-a-pr)
- [ ] [Add `[feature]` if the change is significant or affects feature tests](https://github.com/PowerShell/PowerShell/blob/master/docs/testing-guidelines/testing-guidelines.md#requesting-additional-tests-for-a-pr)
- [ ] This PR is ready to merge and is not [Work in Progress](https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request---work-in-progress).
- If the PR is work in progress, please add the prefix `WIP:` to the beginning of the title and remove the prefix when the PR is ready.
15 changes: 9 additions & 6 deletions assets/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@
<?define InfoURL="https://github.com/PowerShell/PowerShell" ?>
<?define ProductName = "$(env.ProductName)" ?>
<?define ProductGuid = "$(env.ProductGuid)" ?>
<!-- UpgradeCode GUID MUST REMAIN SAME THROUGHOUT ALL VERSIONS, otherwise, updates won't occur. -->
<?if $(sys.BUILDARCH)=x64?>
<?define UpgradeCode = "31ab5147-9a97-4452-8443-d9709f0516e1" ?>
<?else?>
<?define UpgradeCode = "1d00683b-0f84-4db8-a64f-2f98ad42fe06" ?>
<?endif?>
<?define ProductVersion = "$(env.ProductVersion)" ?>
<?define ProductSemanticVersion = "$(env.ProductSemanticVersion)" ?>
<?define ProductVersionWithName = "$(var.ProductName)_$(var.ProductVersion)"?>
<?define ProductSemanticVersionWithName = "$(var.ProductName)-$(env.ProductSemanticVersion)"?>
<?define ProductTargetArchitecture = "$(env.ProductTargetArchitecture)"?>
<?define ProductProgFilesDir = "$(env.ProductProgFilesDir)" ?>
<!-- Generate Your Own GUID for both ID and UpgradeCode attributes. -->
<!-- Note: UpgradeCode GUID MUST REMAIN SAME THROUGHOUT ALL VERSIONS -->
<!-- Otherwise, updates won't occur -->
<Product Id="$(var.ProductGuid)" Name="$(var.ProductSemanticVersionWithName)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Microsoft Corporation" UpgradeCode="{f7ba3e58-0be8-443b-ac91-f99dd1e7bd3b}">
<!-- The ProductCode is Product Id: http://wixtoolset.org/documentation/manual/v3/xsd/wix/product.html -->
<Product Id="$(var.ProductGuid)" Name="$(var.ProductSemanticVersionWithName)-$(sys.BUILDARCH)" Language="1033" Version="$(var.ProductVersion)" Manufacturer="Microsoft Corporation" UpgradeCode="$(var.UpgradeCode)">
<!-- Properties About The Package -->
<Package Id="*" Keywords="Installer" Platform="$(var.ProductTargetArchitecture)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="PowerShell package" Comments="PowerShell for every system" />
<Package Id="*" Keywords="Installer" Platform="$(sys.BUILDARCH)" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="PowerShell package" Comments="PowerShell for every system" />
<!-- Add PowerShell icon for executable -->
<Icon Id="PowerShellExe.ico" SourceFile="assets\Powershell_black.ico" />
<!-- Add PowerShell icon in Add/Remove Programs -->
Expand Down
28 changes: 14 additions & 14 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,8 @@ function Test-PSPesterResults

function Start-PSxUnit {
[CmdletBinding()]param(
[string] $TestResultsFile = "XUnitResults.xml"
[string] $SequentialTestResultsFile = "SequentialXUnitResults.xml",
[string] $ParallelTestResultsFile = "ParallelXUnitResults.xml"
)

# Add .NET CLI tools to PATH
Expand All @@ -1375,9 +1376,11 @@ function Start-PSxUnit {
throw "PowerShell must be built before running tests!"
}

if(Test-Path $TestResultsFile)
{
Remove-Item $TestResultsFile -Force -ErrorAction SilentlyContinue
if (Test-Path $SequentialTestResultsFile) {
Remove-Item $SequentialTestResultsFile -Force -ErrorAction SilentlyContinue
}
if (Test-Path $ParallelTestResultsFile) {
Remove-Item $ParallelTestResultsFile -Force -ErrorAction SilentlyContinue
}

try {
Expand All @@ -1386,12 +1389,7 @@ function Start-PSxUnit {
# Path manipulation to obtain test project output directory
dotnet restore

# --fx-version workaround required due to https://github.com/dotnet/cli/issues/7901#issuecomment-343323674
if($Environment.IsWindows)
{
dotnet xunit --fx-version 2.0.0 -xml $TestResultsFile
}
else
if(-not $Environment.IsWindows)
{
if($Environment.IsMacOS)
{
Expand Down Expand Up @@ -1419,9 +1417,12 @@ function Start-PSxUnit {
{
throw "Dependencies $requiredDependencies not met."
}

dotnet xunit --fx-version 2.0.0 -configuration $Options.configuration -xml $TestResultsFile
}

# '-fxversion' workaround required due to https://github.com/dotnet/cli/issues/7901#issuecomment-343323674
# Run sequential tests first, and then run the tests that can execute in parallel
dotnet xunit -fxversion 2.0.0 -configuration $Options.configuration -xml $SequentialTestResultsFile -namespace "PSTests.Sequential" -parallel none
dotnet xunit -fxversion 2.0.0 -configuration $Options.configuration -xml $ParallelTestResultsFile -namespace "PSTests.Parallel" -nobuild
}
finally {
Pop-Location
Expand Down Expand Up @@ -2140,7 +2141,6 @@ function New-MSIPackage
[Environment]::SetEnvironmentVariable("ProductVersion", $ProductVersion, "Process")
[Environment]::SetEnvironmentVariable("ProductSemanticVersion", $ProductSemanticVersion, "Process")
[Environment]::SetEnvironmentVariable("ProductVersionWithName", $productVersionWithName, "Process")
[Environment]::SetEnvironmentVariable("ProductTargetArchitecture", $ProductTargetArchitecture, "Process")
$ProductProgFilesDir = "ProgramFiles64Folder"
if ($ProductTargetArchitecture -eq "x86")
{
Expand All @@ -2164,7 +2164,7 @@ function New-MSIPackage
}

$WiXHeatLog = & $wixHeatExePath dir $ProductSourcePath -dr $productVersionWithName -cg $productVersionWithName -gg -sfrag -srd -scom -sreg -out $wixFragmentPath -var env.ProductSourcePath -v
$WiXCandleLog = & $wixCandleExePath "$ProductWxsPath" "$wixFragmentPath" -out (Join-Path "$env:Temp" "\\") -ext WixUIExtension -ext WixUtilExtension -arch x64 -v
$WiXCandleLog = & $wixCandleExePath "$ProductWxsPath" "$wixFragmentPath" -out (Join-Path "$env:Temp" "\\") -ext WixUIExtension -ext WixUtilExtension -arch $ProductTargetArchitecture -v
$WiXLightLog = & $wixLightExePath -out $msiLocationPath $wixObjProductPath $wixObjFragmentPath -ext WixUIExtension -ext WixUtilExtension -dWixUILicenseRtf="$LicenseFilePath" -v

Remove-Item -ErrorAction SilentlyContinue *.wixpdb -Force
Expand Down
4 changes: 4 additions & 0 deletions docs/installation/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ dpkg -r powershell_6.0.0-rc.2-1.ubuntu.16.04_amd64.deb

Currently, PowerShell is only supported on Raspbian Stretch.

Also CoreCLR (and thus PowerShell Core) will only work on Pi 2 and Pi 3 devices as other devices like [Pi Zero](https://github.com/dotnet/coreclr/issues/10605) have an unsupported processor.

Download [Raspbian Stretch](https://www.raspberrypi.org/downloads/raspbian/) and follow the [installation instructions](https://www.raspberrypi.org/documentation/installation/installing-images/README.md) to get it onto your Pi.

### Installation

```sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.IO;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Configuration;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Internal;
using System.Diagnostics;
Expand Down Expand Up @@ -459,29 +460,17 @@ internal void Parse(string[] args)
}
}

private static string s_groupPolicyBase = @"Software\Policies\Microsoft\Windows\PowerShell";
private static string s_consoleSessionConfigurationKey = "ConsoleSessionConfiguration";
private static string s_enableConsoleSessionConfiguration = "EnableConsoleSessionConfiguration";
private static string s_consoleSessionConfigurationName = "ConsoleSessionConfigurationName";
private static string GetConfigurationNameFromGroupPolicy()
{
// Current user policy takes precedence.
var groupPolicySettings = Utils.GetGroupPolicySetting(s_groupPolicyBase, s_consoleSessionConfigurationKey, Utils.RegCurrentUserThenLocalMachine);
if (groupPolicySettings != null)
var consoleSessionSetting = Utils.GetPolicySetting<ConsoleSessionConfiguration>(Utils.CurrentUserThenSystemWideConfig);
if (consoleSessionSetting != null)
{
object keyValue;
if (groupPolicySettings.TryGetValue(s_enableConsoleSessionConfiguration, out keyValue))
if (consoleSessionSetting.EnableConsoleSessionConfiguration == true)
{
if (String.Equals(keyValue.ToString(), "1", StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrEmpty(consoleSessionSetting.ConsoleSessionConfigurationName))
{
if (groupPolicySettings.TryGetValue(s_consoleSessionConfigurationName, out keyValue))
{
string consoleSessionConfigurationName = keyValue.ToString();
if (!string.IsNullOrEmpty(consoleSessionConfigurationName))
{
return consoleSessionConfigurationName;
}
}
return consoleSessionSetting.ConsoleSessionConfigurationName;
}
}
}
Expand Down
53 changes: 0 additions & 53 deletions src/System.Management.Automation/engine/CommandDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1643,59 +1643,6 @@ private int GetCmdletRemovalIndex(List<CmdletInfo> cacheEntry, string PSSnapin)

internal ExecutionContext Context { get; }

/// <summary>
/// Reads the path for the appropriate shellID from the registry.
/// </summary>
///
/// <param name="shellID">
/// The ID of the shell to retrieve the path for.
/// </param>
///
/// <returns>
/// The path to the shell represented by the shellID.
/// </returns>
///
/// <remarks>
/// The shellID must be registered in the Windows Registry in either
/// the HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE hive under
/// Software/Microsoft/MSH/&lt;ShellID&gt; and are searched in that order.
/// </remarks>
///
internal static string GetShellPathFromRegistry(string shellID)
{
string result = null;

#if !UNIX
try
{
RegistryKey shellKey = Registry.LocalMachine.OpenSubKey(Utils.GetRegistryConfigurationPath(shellID));
if (shellKey != null)
{
// verify the value kind as a string
RegistryValueKind kind = shellKey.GetValueKind("path");

if (kind == RegistryValueKind.ExpandString ||
kind == RegistryValueKind.String)
{
result = shellKey.GetValue("path") as string;
}
}
}
// Ignore these exceptions and return an empty or null result
catch (SecurityException)
{
}
catch (IOException)
{
}
catch (ArgumentException)
{
}
#endif

return result;
}

internal static PSModuleAutoLoadingPreference GetCommandDiscoveryPreference(ExecutionContext context, VariablePath variablePath, string environmentVariable)
{
Dbg.Assert(context != null, "context cannot be Null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4639,7 +4639,6 @@ internal static SessionStateAliasEntry[] BuiltInAliases
new SessionStateAliasEntry("rvpa", "Resolve-Path", "", ReadOnly),
new SessionStateAliasEntry("sal", "Set-Alias", "", ReadOnly),
new SessionStateAliasEntry("sbp", "Set-PSBreakpoint", "", ReadOnly),
new SessionStateAliasEntry("sc", "Set-Content", "", ReadOnly),
new SessionStateAliasEntry("select", "Select-Object", "", ReadOnly_AllScope),
new SessionStateAliasEntry("si", "Set-Item", "", ReadOnly),
new SessionStateAliasEntry("sl", "Set-Location", "", ReadOnly),
Expand Down Expand Up @@ -4688,13 +4687,14 @@ internal static SessionStateAliasEntry[] BuiltInAliases
new SessionStateAliasEntry("type", "Get-Content"),
// Native commands we keep because the functions act correctly on Linux
new SessionStateAliasEntry("clear", "Clear-Host"),
//#if !CORECLR is used to disable aliases for cmdlets which are not available on OneCore
//#if !CORECLR is used to disable aliases for cmdlets which are not available on OneCore or not appropriate for PSCore6 due to conflicts
#if !CORECLR
new SessionStateAliasEntry("gwmi", "Get-WmiObject", "", ReadOnly),
new SessionStateAliasEntry("iwmi", "Invoke-WMIMethod", "", ReadOnly),
new SessionStateAliasEntry("ogv", "Out-GridView", "", ReadOnly),
new SessionStateAliasEntry("ise", "powershell_ise.exe", "", ReadOnly),
new SessionStateAliasEntry("rwmi", "Remove-WMIObject", "", ReadOnly),
new SessionStateAliasEntry("sc", "Set-Content", "", ReadOnly),
new SessionStateAliasEntry("swmi", "Set-WMIInstance", "", ReadOnly),
new SessionStateAliasEntry("shcm", "Show-Command", "", ReadOnly),
new SessionStateAliasEntry("trcm", "Trace-Command", "", ReadOnly),
Expand Down
29 changes: 10 additions & 19 deletions src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Configuration;
using System.Management.Automation.Internal;
using System.Management.Automation.Runspaces;
using System.Management.Automation.Security;
Expand Down Expand Up @@ -4749,28 +4750,18 @@ internal static ModuleLoggingGroupPolicyStatus GetModuleLoggingInformation(out I
{
moduleNames = null;
ModuleLoggingGroupPolicyStatus status = ModuleLoggingGroupPolicyStatus.Undefined;
Dictionary<string, object> groupPolicySettings = Utils.GetGroupPolicySetting("ModuleLogging", Utils.RegLocalMachineThenCurrentUser);

if (groupPolicySettings != null)
var moduleLogging = Utils.GetPolicySetting<ModuleLogging>(Utils.SystemWideThenCurrentUserConfig);
if (moduleLogging != null)
{
object enableModuleLoggingValue = null;
if (groupPolicySettings.TryGetValue("EnableModuleLogging", out enableModuleLoggingValue))
if (moduleLogging.EnableModuleLogging == false)
{
if (String.Equals(enableModuleLoggingValue.ToString(), "0", StringComparison.OrdinalIgnoreCase))
{
return ModuleLoggingGroupPolicyStatus.Disabled;
}

if (String.Equals(enableModuleLoggingValue.ToString(), "1", StringComparison.OrdinalIgnoreCase))
{
status = ModuleLoggingGroupPolicyStatus.Enabled;

object moduleNamesValue = null;
if (groupPolicySettings.TryGetValue("ModuleNames", out moduleNamesValue))
{
moduleNames = new List<String>((string[])moduleNamesValue);
}
}
status = ModuleLoggingGroupPolicyStatus.Disabled;
}
else if (moduleLogging.EnableModuleLogging == true)
{
status = ModuleLoggingGroupPolicyStatus.Enabled;
moduleNames = moduleLogging.ModuleNames;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Collections.Generic;
using System.IO;
using System.Management.Automation.Configuration;
using System.Management.Automation.Internal;
using System.Management.Automation.Language;
using Microsoft.PowerShell.Commands;
Expand Down Expand Up @@ -977,8 +978,8 @@ internal static string GetModulePath()
internal static string SetModulePath()
{
string currentModulePath = GetExpandedEnvironmentVariable(Constants.PSModulePathEnvVar, EnvironmentVariableTarget.Process);
string systemWideModulePath = ConfigPropertyAccessor.Instance.GetModulePath(ConfigPropertyAccessor.PropertyScope.SystemWide);
string personalModulePath = ConfigPropertyAccessor.Instance.GetModulePath(ConfigPropertyAccessor.PropertyScope.CurrentUser);
string systemWideModulePath = PowerShellConfig.Instance.GetModulePath(ConfigScope.SystemWide);
string personalModulePath = PowerShellConfig.Instance.GetModulePath(ConfigScope.CurrentUser);

string newModulePathString = GetModulePath(currentModulePath, systemWideModulePath, personalModulePath);

Expand Down
Loading