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
6 changes: 3 additions & 3 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ try {
$Runtime = [System.Runtime.InteropServices.RuntimeInformation]
$OSPlatform = [System.Runtime.InteropServices.OSPlatform]

$IsCore = $true
$IsCoreCLR = $true
$IsLinux = $Runtime::IsOSPlatform($OSPlatform::Linux)
$IsOSX = $Runtime::IsOSPlatform($OSPlatform::OSX)
$IsWindows = $Runtime::IsOSPlatform($OSPlatform::Windows)
} catch {
# If these are already set, then they're read-only and we're done
try {
$IsCore = $false
$IsCoreCLR = $false
$IsLinux = $false
$IsOSX = $false
$IsWindows = $true
Expand Down Expand Up @@ -602,7 +602,7 @@ function Start-PSBootstrap {
}

# Install for Windows
if ($IsWindows -and -not $IsCore) {
if ($IsWindows -and -not $IsCoreCLR) {
Remove-Item -ErrorAction SilentlyContinue -Recurse -Force ~\AppData\Local\Microsoft\dotnet
$installScript = "dotnet-install.ps1"
Invoke-WebRequest -Uri $obtainUrl/$installScript -OutFile $installScript
Expand Down
10 changes: 5 additions & 5 deletions src/Modules/Shared/PowerShellGet/PSModule.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $script:isNanoServer = $null -ne ('System.Runtime.Loader.AssemblyLoadContext' -a
function IsWindows { $PSVariable = Get-Variable -Name IsWindows -ErrorAction Ignore; return (-not $PSVariable -or $PSVariable.Value) }
function IsLinux { $PSVariable = Get-Variable -Name IsLinux -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
function IsOSX { $PSVariable = Get-Variable -Name IsOSX -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
function IsCore { $PSVariable = Get-Variable -Name IsCore -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }
function IsCoreCLR { $PSVariable = Get-Variable -Name IsCoreCLR -ErrorAction Ignore; return ($PSVariable -and $PSVariable.Value) }

if(IsWindows)
{
Expand Down Expand Up @@ -727,7 +727,7 @@ function Publish-Module

Begin
{
if($script:isNanoServer -or (IsCore)) {
if($script:isNanoServer -or (IsCoreCLR)) {
$message = $LocalizedData.PublishPSArtifactUnsupportedOnNano -f "Module"
ThrowError -ExceptionName "System.InvalidOperationException" `
-ExceptionMessage $message `
Expand Down Expand Up @@ -2526,7 +2526,7 @@ function Publish-Script

Begin
{
if($script:isNanoServer -or (IsCore)) {
if($script:isNanoServer -or (IsCoreCLR)) {
$message = $LocalizedData.PublishPSArtifactUnsupportedOnNano -f "Script"
ThrowError -ExceptionName "System.InvalidOperationException" `
-ExceptionMessage $message `
Expand Down Expand Up @@ -7322,7 +7322,7 @@ function Install-NuGetClientBinaries
}

# On Nano server we don't need NuGet.exe
if(-not $bootstrapNuGetProvider -and ($script:isNanoServer -or (IsCore) -or -not $BootstrapNuGetExe))
if(-not $bootstrapNuGetProvider -and ($script:isNanoServer -or (IsCoreCLR) -or -not $BootstrapNuGetExe))
{
return
}
Expand Down Expand Up @@ -7379,7 +7379,7 @@ function Install-NuGetClientBinaries
}
}

if($BootstrapNuGetExe -and -not $script:isNanoServer -and -not (IsCore))
if($BootstrapNuGetExe -and -not $script:isNanoServer -and -not (IsCoreCLR))
{
Write-Verbose -Message $LocalizedData.DownloadingNugetExe

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static bool IsWindows
/// <summary>
/// True if PowerShell was built targeting .NET Core.
/// </summary>
public static bool IsCore
public static bool IsCoreCLR
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,8 +1815,7 @@ private StringResourceReference LoadResourceAttributes (XmlAttributeCollection a


// optional pre-load and binding verification
// Porting Note: DLL.resources are not currently available on Linux
if (!Platform.IsCore && this.VerifyStringResources)
if (this.VerifyStringResources)
{
DisplayResourceManagerCache.LoadingResult result;
DisplayResourceManagerCache.AssemblyBindingStatus bindingStatus;
Expand Down
6 changes: 4 additions & 2 deletions src/System.Management.Automation/engine/CommandDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,14 +1321,16 @@ private static CommandInfo TryModuleAutoDiscovery(string commandName,
}
}

// TODO: this causes AppVeyor builds to fail due to invalid XML being output
#if !CORECLR
// Close the progress pane that may have popped up from analyzing UNC paths.
// Porting note: we don't like this message
if (!Platform.IsCore && context.CurrentCommandProcessor != null)
if (context.CurrentCommandProcessor != null)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

James Truher (@JamesWTruher) this was the bug. I'd removed this guard, and didn't expect anything to fail. The note I'd left myself was just that it left a useless message on *nix. However, it's apparently causing the bug with bad XML output on the error stream.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a partial fix and a wrong one at that.

By not calling WriteProgress with a Completed message, we'll leave screen artifacts. See the corresponding call in SriptAnalysis.cs, line 43 - that code is not guarded at all by #if !CORECLR

I don't have a strong preference on this specific progress message, but if progress messages are causing problems in CI, turning them off this way is not the right fix.


In reply to: 72326595 [](ancestors = 72326595)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is status quo currently. It was already disabled for CoreCLR builds, and remains disabled.

I agree there is a bug here. I'll file an issue, but it's separate from this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #1524.

{
ProgressRecord analysisProgress = new ProgressRecord(0, Modules.ScriptAnalysisPreparing, " ");
analysisProgress.RecordType = ProgressRecordType.Completed;
context.CurrentCommandProcessor.CommandRuntime.WriteProgress(analysisProgress);
}
#endif
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/System.Management.Automation/engine/InitialSessionState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5122,8 +5122,8 @@ .ForwardHelpCategory Cmdlet
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),

new SessionStateVariableEntry(
SpecialVariables.IsCore,
Platform.IsCore,
SpecialVariables.IsCoreCLR,
Platform.IsCoreCLR,
String.Empty,
ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope),
#endregion
Expand Down Expand Up @@ -5475,7 +5475,7 @@ internal static SessionStateAliasEntry[] BuiltInAliases
internal const string DefaultMoreFunctionText = @"
param([string[]]$paths)
# Nano needs to use Unicode, but Windows and Linux need the default
$OutputEncoding = if ($IsWindows -and $IsCore) {
$OutputEncoding = if ($IsWindows -and $IsCoreCLR) {
[System.Text.Encoding]::Unicode
} else {
[System.Console]::OutputEncoding
Expand Down Expand Up @@ -5698,11 +5698,7 @@ internal static Assembly LoadPSSnapInAssembly(PSSnapInInfo psSnapInInfo,
{
AssemblyName assemblyName = ClrFacade.GetAssemblyName(psSnapInInfo.AbsoluteModulePath);

// Porting note: the snapins still require 'ProcessorArchitecture=MSIL' in
// the strong name, which is not in the strong name of assemblies created
// by dotnet-cli
if (!Platform.IsCore &&
!string.Equals(assemblyName.FullName, psSnapInInfo.AssemblyName, StringComparison.OrdinalIgnoreCase))
if (!string.Equals(assemblyName.FullName, psSnapInInfo.AssemblyName, StringComparison.OrdinalIgnoreCase))
{
string message = StringUtil.Format(ConsoleInfoErrorStrings.PSSnapInAssemblyNameMismatch, psSnapInInfo.AbsoluteModulePath, psSnapInInfo.AssemblyName);
_PSSnapInTracer.TraceError(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,12 +778,13 @@ public static string GetModulePath(string currentProcessModulePath, string hklmM
{
// Now handle the case where the environment variable is already set.

// Porting note: Open PowerShell has a Modules folder in the the application base path which contains the built-in modules
// It must be in the front of the path no matter what.
if (Platform.IsCore)
{
currentProcessModulePath = AddToPath(currentProcessModulePath, GetSystemwideModulePath(), 0);
}
// CoreCLR PowerShell on Windows has a Modules folder in the the application base
// path which contains the built-in modules It must be in the front of the path no
// matter what, regardless of inherited path.
#if CORECLR && !UNIX
// TODO: #1184 will resolve this work-around
currentProcessModulePath = AddToPath(currentProcessModulePath, GetSystemwideModulePath(), 0);
#endif

// If there is no personal path key, then if the env variable doesn't match the system variable,
// the user modified it somewhere, else prepend the default personel module path
Expand Down
4 changes: 2 additions & 2 deletions src/System.Management.Automation/engine/SpecialVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ static class SpecialVariables
internal const string IsWindows = "IsWindows";
internal static VariablePath IsWindowsPath = new VariablePath("IsWindows");

internal const string IsCore = "IsCore";
internal static VariablePath IsCorePath = new VariablePath("IsCore");
internal const string IsCoreCLR = "IsCoreCLR";
internal static VariablePath IsCoreCLRPath = new VariablePath("IsCoreCLR");

#endregion
#region Preference Variables
Expand Down
33 changes: 18 additions & 15 deletions src/System.Management.Automation/engine/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,18 @@ internal static string GetApplicationBaseFromRegistry(string shellId)
/// </exception>
internal static string GetApplicationBase(string shellId)
{
if (!Platform.IsCore)
// TODO: #1184 will resolve this work-around
// The application base cannot be resolved from the registry for side-by-side versions
// of PowerShell.
#if !CORECLR
// try to get the path from the registry first
string result = GetApplicationBaseFromRegistry(shellId);
if (result != null)
{
// try to get the path from the registry first
string result = GetApplicationBaseFromRegistry(shellId);
if (result != null)
{
return result;
}
return result;
}
#endif


#if CORECLR // Use the location of SMA.dll as the application base
// Assembly.GetEntryAssembly is not in CoreCLR. GAC is not in CoreCLR.
Expand Down Expand Up @@ -296,14 +299,14 @@ private static string[] GetProductFolderDirectories()

// And built-in modules
string progFileDir;
if (Platform.IsCore)
{
progFileDir = Path.Combine(appBase, "Modules");
}
else
{
progFileDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsPowerShell", "Modules");
}
// TODO: #1184 will resolve this work-around
// Side-by-side versions of PowerShell use modules from their application base, not
// the system installation path.
#if CORECLR
progFileDir = Path.Combine(appBase, "Modules");
#else
progFileDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsPowerShell", "Modules");
#endif

if (!string.IsNullOrEmpty(progFileDir))
{
Expand Down
4 changes: 2 additions & 2 deletions test/csharp/test_CorePsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace PSTests
public static class PlatformTests
{
[Fact]
public static void TestIsCore()
public static void TestIsCoreCLR()
{
Assert.True(Platform.IsCore);
Assert.True(Platform.IsCoreCLR);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion test/powershell/Host/PSVersionTable.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Describe "PSVersionTable" {
$PSVersionTable.GitCommitId | Should not match "powershell.version"
}

It "Should have the correct edition" -Skip:(!$IsCore) {
It "Should have the correct edition" -Skip:(!$IsCoreCLR) {
$PSVersionTable["PSEdition"] | Should Be "PowerShellCore"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ Describe 'PositiveReturnSelfClassTypeFromMemberFunction Test' -Tags "CI" {
}

Describe 'TestMultipleArguments Test' -Tags "CI" {
if ( $IsCore ) { $maxCount = 14 } else { $maxCount = 16 }
if ( $IsCoreCLR ) { $maxCount = 14 } else { $maxCount = 16 }
for ($i = 0; $i -lt $maxCount; $i++)
{
$properties = $(for ($j = 0; $j -le $i; $j++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ( $IsCore ) {
if ( $IsCoreCLR ) {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Describe "Type accelerators" -Tags "DRT" {
}

It "Can query type accelerators" {
if ( $IsCore ) { $count = 80 } else { $count = 82 }
if ( $IsCoreCLR ) { $count = 80 } else { $count = 82 }
$TypeAccelerators.Count -gt $count | Should Be $true
$TypeAccelerators['xml'] | Should Be ([System.Xml.XmlDocument])
$TypeAccelerators['AllowNull'] | Should Be ([System.Management.Automation.AllowNullAttribute])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Describe "Line breakpoints on commands in multi-line pipelines" -tags 'Innerloop
Context "COM TESTS" {
# DRT for 133807 SetBreakpointWithShortPath
BeforeAll {
if ( $IsCore ) { return } # no COM on core
if ( $IsCoreCLR ) { return } # no COM on core
$scriptPath1 = Join-Path $TestDrive SBPShortPathBug133807.DRT.tmp.ps1
$scriptPath1 = setup -f SBPShortPathBug133807.DRT.tmp.ps1 -content '
1..3 |
Expand All @@ -230,19 +230,19 @@ Describe "Line breakpoints on commands in multi-line pipelines" -tags 'Innerloop
}

AfterAll {
if ( $IsCore ) { return }
if ( $IsCoreCLR ) { return }
if ($breakpoints -ne $null) { $breakpoints | Remove-PSBreakpoint }
}

It "Short path Breakpoint on line 1 hit count" -skip:$IsCore {
It "Short path Breakpoint on line 1 hit count" -skip:$IsCoreCLR {
$breakpoints[0].HitCount | Should Be 1
}

It "Short path Breakpoint on line 2 hit count" -skip:$IsCore {
It "Short path Breakpoint on line 2 hit count" -skip:$IsCoreCLR {
$breakpoints[1].HitCount | Should Be 3
}

It "Short path Breakpoint on line 3 hit count" -skip:$IsCore {
It "Short path Breakpoint on line 3 hit count" -skip:$IsCoreCLR {
$breakpoints[2].HitCount | Should Be 1
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ($IsWindows -and !$IsCore) {
if ($IsWindows -and !$IsCoreCLR) {
#check to see whether we're running as admin in Windows...
$windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ($IsWindows -and !$IsCore) {
if ($IsWindows -and !$IsCoreCLR) {
#check to see whether we're running as admin in Windows...
$windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ($IsWindows -and !$IsCore) {
if ($IsWindows -and !$IsCoreCLR) {
#check to see whether we're running as admin in Windows...
$windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ($IsWindows -and !$IsCore) {
if ($IsWindows -and !$IsCoreCLR) {
#check to see whether we're running as admin in Windows...
$windowsIdentity = [Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'Security.Principal.WindowsPrincipal' $windowsIdentity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ Describe "Invoke-Item" {
$testfile = Join-Path $TestDrive testfile.txt
}

It "Should invoke a text file without error" -Skip:($IsWindows -and $IsCore) {
It "Should invoke a text file without error" -Skip:($IsWindows -and $IsCoreCLR) {
$debugfn = NewProcessStartInfo "-noprofile ""``Invoke-Item $testfile`n" -RedirectStdIn
$process = RunPowerShell $debugfn
EnsureChildHasExited $process
$process.ExitCode | Should Be 0
}

It "Should throw not supported on Windows with .NET Core" -Skip:($IsLinux -or $IsOSX -or !$IsCore) {
It "Should throw not supported on Windows with .NET Core" -Skip:($IsLinux -or $IsOSX -or !$IsCoreCLR) {
{ Invoke-Item $testfile }| Should Throw "Operation is not supported on this platform."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Describe "Trace-Command" -tags "P1", "RI" {
}

# LogicalOperationStack is not in .NET Core
It "LogicalOperationStack works" -Skip:$IsCore {
It "LogicalOperationStack works" -Skip:$IsCoreCLR {
$keyword = "Trace_Command_ListenerOption_LogicalOperationStack_Foo"
$stack = [System.Diagnostics.Trace]::CorrelationManager.LogicalOperationStack
$stack.Push($keyword)
Expand All @@ -25,7 +25,7 @@ Describe "Trace-Command" -tags "P1", "RI" {
}

# GetStackTrace is not in .NET Core
It "Callstack works" -Skip:$IsCore {
It "Callstack works" -Skip:$IsCoreCLR {
Trace-Command -Name * -Expression {echo Foo} -ListenerOption Callstack -FilePath $logfile
$log = Get-Content $logfile | Where-Object {$_ -like "*Callstack= * System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)*"}
$log.Count | Should BeGreaterThan 0
Expand Down