Skip to content

Implement Invoke-Item/Get-Help -Online for .NET Core on Windows and Nano #1325

Closed

Description

Per #1291, we've discovered that Invoke-Item and Get-Help -Online are broken for .NET Core on Windows and Nano due to UseShellExecute being unavailable.

One approach for Windows (but not Nano) is recorded in 6200f08. While this works for .NET Core on Windows by shelling out to cmd.exe "start ..." (essentially replacing UseShellExecute) it still poses a problem on Nano as the latter won't have any browser (or other default applications) to invoke.

At this point, PowerShell does not really differentiate between PowerShell on Nano and PowerShell on Windows built with .NET Core, but the latter has become a valid, and different, flavor with PowerShell Core. We'll need a proper way to detect whether or not the underlying OS is Nano, without depending on the target framework being .NET Core. (Done: [System.Management.Automation.Platform]::IsIoT and [System.Management.Automation.Platform]::IsNanoServer)

Breaking down issue 1325 into two as they required different approaches.

To fix this issue, a possible solution is to wrap the call in cmd.exe “start...”; however, in order to figure out if the process fail to start, we need WaitForExit, then check the exit code, and extract the standard error. This is a change on behavior between Full and CoreCLR PowerShell. The problem with this implementation is that PowerShell will be blocked until the process completes. Alternatively, if we decide to just ignore the error, then this behavior will also be incorrect since in PowerShell no error means the operation was successful.
We should explore doing a PInvoke in Windows CoreCLR. This way, we can get the Marshal.GetLastWin32Error() if we fail to start the process.

To fix this issue, we should write code that checks if there is default browser. If there isn’t (which is the Nano Server and IoT scenario), we error out. If there is, we can wrap the call in cmd.exe “start …”

Activity

  1. added this to the Aug17 milestone on Jul 8, 2016
  2. modified the milestones: , Future on Jul 26, 2016
  3. andyleejordan commented on Jul 26, 2016

    @andyleejordan
    MemberAuthor

    Moving milestone per #1506.

  4. modified the milestones: , on Aug 4, 2016
  5. iSazonov commented on Oct 7, 2016

    @iSazonov
    Collaborator

    Andy Jordan (@andschwa) IsNanoServer and IsIoT is defined in CorePsPlatform.cs
    (May be add their to SpecialVariables.cs for use in tests?)

  6. andyleejordan commented on Oct 7, 2016

    @andyleejordan
    MemberAuthor

    Ilya (@iSazonov) They weren't in July 😄 and this is owned by Francisco Gamino (@Francisco-Gamino)

  7. iSazonov commented on Oct 8, 2016

    @iSazonov
    Collaborator

    Andy Jordan (@andschwa) Thanks for the clarification.
    Could you please strike through the text?

    At this point, PowerShell does not really differentiate between PowerShell on Nano and PowerShell > on Windows built with .NET Core, but the latter has become a valid, and different, flavor with PowerShell Core. ~~~We'll need a proper way to detect whether or not the underlying OS is Nano, without depending on the target framework being .NET Core.~~~ (Done)

    Andy Jordan (@andschwa) and Francisco Gamino (@Francisco-Gamino) Whether to open a new issue for "add IsNanoServer and IsIoT to SpecialVariables.cs for use in tests"?

  8. daxian-dbw commented on Oct 10, 2016

    @daxian-dbw
    Member

    Ilya (@iSazonov) I updated the issue description to make it clearer.

    I'm a little hesitating about adding automatic variable $IsIoT and $IsNanoServer in powershell core. Differences between powershell core on windows and Nano/IoT powershell are mainly in:

    1. Configurations, such as module path, profile path, whether to use configuration json file or registry.
      -- the difference should be transparent to user: $env:psmodulepath and $profile will have the correct setting on those platforms.
    2. Native Win32 API coverage
      -- $IsIoT and $IsNanoServer could be helpful when a module implementation depends on native win32 APIs. But I guess that's not common and you can always check $PSHome to tell if you are running on a inbox powershell (indicating NanoServer and IoT).

    Given that, I feel it's possibly more like a developer's need to have $IsIoT and $IsNanoServer -- easier to write tests, not a user's need.

  9. iSazonov commented on Oct 11, 2016

    @iSazonov
    Collaborator

    Dongbo Wang (@daxian-dbw) Thanks for the update.

    If [System.Management.Automation.Platform]::IsIoT and [System.Management.Automation.Platform]::IsNanoServer can be used in the tests, then my question is closed.
    Discussion about adding variables and end user UX I believe should be in a separate Issue.

  10. daxian-dbw commented on Oct 12, 2016

    @daxian-dbw
    Member

    This issue has been separated into 2 sub issues: Get-Help -Online (#2271) and Invoke-Item (#2272).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions