Skip to content

TestPathCommand and several others removed in PowerShell 7.2 SDK #16862

Closed

Description

@colinblaise

Prerequisites

Steps to reproduce

Using C# SDK, I updated Microsoft.PowerShell.Commands.Management from 7.1.5 to 7.2.1.

The SDK no longer has references to the following commands:

  1. JoinPathCommand
  2. TestPathCommand
  3. GetChildItemCommand
  4. GetItemCommand
  5. SetItemCommand

If this was intentional, how should I be referencing these commands?

Expected behavior

I need to import the commands listed under steps to reproduce

Actual behavior

I can now longer use the commands listed under steps to reproduce

Error details

No response

Environment data

Key                       Value
---                       -----
PSVersion                 7.2.1
PSEdition                 Core
GitCommitId               7.2.1
OS                        Linux 5.10.60.1-microsoft-standard-WSL2 #1 SMP Wed Aug 25 23:20:18 UTC 2021
Platform                  Unix
PSCompatibleVersions      {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion      1.1.0.1
WSManStackVersion         3.0

Visuals

No response

Activity

  1. added
    WG-DevEx-SDKhosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of modules
    on Feb 9, 2022
  2. colinblaise commented on Feb 9, 2022

    @colinblaise
    Author

    Related - #16141

  3. dkattan commented on Mar 7, 2022

    @dkattan
    Contributor

    Further, if you try to include Microsoft.PowerShell.Commands.Management from NuGet you get the error:

    Assembly 'Microsoft.PowerShell.Commands.Management' with identity 'Microsoft.PowerShell.Commands.Management, Version=7.3.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Management.Automation, Version=7.3.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Management.Automation' with identity 'System.Management.Automation, Version=7.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

  4. dkattan commented on Dec 5, 2022

    @dkattan
    Contributor

    Patrick Meinecke (@SeeminglyScience) Aditya Mandaleeka (@adityamandaleeka) Travis Plunk (@TravisEz13)

    There are 2 problems:

    1. Microsoft.PowerShell.SDK is missing an assembly reference to Microsoft.PowerShell.Commands.Management.dll, Microsoft.PowerShell.Commands.Diagnostics, Microsoft.PowerShell.Security, and Microsoft.WSMan.Management
    2. Microsoft.PowerShell.Commands.Management references System.Management.Automation.dll 7.3.0.500 while Microsoft.PowerShell.SDK references 7.3.0.0

    Personally, I don't really care about 2 because I only needed it due to the missing reference in Microsoft.PowerShell.SDK

    Problem 1

    image

    image

    I believe to fix it we need to the missing assemblies to the $supportedRefList array to this block of code:

    $supportedRefList = @(
    "Microsoft.PowerShell.Commands.Utility",
    "Microsoft.PowerShell.ConsoleHost")

    and also to

    $assemblyNames = @(
    "System.Management.Automation",
    "Microsoft.PowerShell.Commands.Utility",
    "Microsoft.PowerShell.ConsoleHost"
    )

    Problem 2

    If you are interested in also fixing the mismatch in problem 2, if you add a hintpath you can get Visual Studio to tell you more information about the issue:

    Before

    <ItemGroup>
        <PackageReference Include="Microsoft.PowerShell.SDK" Version="7.1.5" />
        <PackageReference Include="Microsoft.PowerShell.Commands.Management" Version="7.1.5"/>
    </ItemGroup>

    After

    <ItemGroup>
        <PackageReference Include="Microsoft.PowerShell.SDK" Version="7.1.5" />
        <PackageReference Include="Microsoft.PowerShell.Commands.Management" Version="7.1.5">
          <GeneratePathProperty>True</GeneratePathProperty>
        </PackageReference>
      </ItemGroup>
    
      <ItemGroup>
        <Reference Include="Microsoft.PowerShell.Commands.Management"> 
    <HintPath>$(PkgMicrosoft_powershell_commands_management)\runtimes\unix\lib\net6.0\Microsoft.PowerShell.Commands.Management.dll</HintPath>
        </Reference>
      </ItemGroup>
    Found conflicts between different versions of "System.Management.Automation" that could not be resolved.
    There was a conflict between "System.Management.Automation, Version=7.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Management.Automation, Version=7.3.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
        "System.Management.Automation, Version=7.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "System.Management.Automation, Version=7.3.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
        References which depend on "System.Management.Automation, Version=7.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Users\DKattan.IN\.nuget\packages\system.management.automation\7.3.0\ref\net7.0\System.Management.Automation.dll].
            C:\Users\DKattan.IN\.nuget\packages\system.management.automation\7.3.0\ref\net7.0\System.Management.Automation.dll
              Project file item includes which caused reference "C:\Users\DKattan.IN\.nuget\packages\system.management.automation\7.3.0\ref\net7.0\System.Management.Automation.dll".
                C:\Users\DKattan.IN\.nuget\packages\system.management.automation\7.3.0\ref\net7.0\System.Management.Automation.dll
        References which depend on "System.Management.Automation, Version=7.3.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [].
            C:\Users\DKattan.IN\.nuget\packages\microsoft.powershell.commands.management\7.3.0\runtimes\unix\lib\net7.0\Microsoft.PowerShell.Commands.Management.dll
              Project file item includes which caused reference "C:\Users\DKattan.IN\.nuget\packages\microsoft.powershell.commands.management\7.3.0\runtimes\unix\lib\net7.0\Microsoft.PowerShell.Commands.Management.dll".
                Microsoft.PowerShell.Commands.Management
    1>CSC : error CS1705: Assembly 'Microsoft.PowerShell.Commands.Management' with identity 'Microsoft.PowerShell.Commands.Management, Version=7.3.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Management.Automation, Version=7.3.0.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Management.Automation' with identity 'System.Management.Automation, Version=7.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
    1>Done building project "TestPowerShell73Dependency2.csproj" -- FAILED.
    
  5. adityapatwardhan commented on Dec 6, 2022

    @adityapatwardhan
    Member

    Darren Kattan (@dkattan) Could you please provide the full csproj? I would like to see the target framework.

    If targeting NET6 -> use Microsoft.Powershell.SDK v 7.2.7
    If targeting NET7 -> use Microsoft.Powershell.SDK v 7.3.0

    v7.1.x is out of support and should not be used. Also, v7.0.x is out of support.

  6. dkattan commented on Dec 9, 2022

    @dkattan
    Contributor

    Darren Kattan (@dkattan) Could you please provide the full csproj? I would like to see the target framework.

    If targeting NET6 -> use Microsoft.Powershell.SDK v 7.2.7 If targeting NET7 -> use Microsoft.Powershell.SDK v 7.3.0

    v7.1.x is out of support and should not be used. Also, v7.0.x is out of support.

    TestPowerShell73Dependency2.zip

    csproj

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
      </PropertyGroup>
    
      <ItemGroup>
        <PackageReference Include="Microsoft.PowerShell.SDK" Version="7.3.0" />
      </ItemGroup>
    
    </Project>

    Program.cs

    // See https://aka.ms/new-console-template for more information
    using System.Management.Automation.Runspaces;
    
    Console.WriteLine("Hello, World!");
    var iss = InitialSessionState.CreateDefault2();
    iss.Commands.Add(new SessionStateCmdletEntry("Resolve-Path", typeof(Microsoft.PowerShell.Commands.ResolvePathCommand), null));

    image

  7. dkattan commented on Dec 21, 2022

    @dkattan
    Contributor

    Patrick Meinecke (@SeeminglyScience) I saw some work done in #18782 v7.4.0-preview.1 related to nuget packages, any chance we can get some traction on this? I just updated my test project to Microsoft.PowerShell.SDK v7.4.0-preview.1 and the problem persists.

  8. dkattan commented on Jan 23, 2023

    @dkattan
    Contributor
  9. bironeaj commented on Jan 23, 2023

    @bironeaj

    Aditya Patwardhan (@adityapatwardhan) we are having this issue too. Any update?

  10. adityapatwardhan commented on Jan 23, 2023

    @adityapatwardhan
    Member

    This issue is not fixed yet. I am working on it and hopefully will be done soon. Thank you for your patience.

  11. bretesq commented on Jan 24, 2023

    @bretesq

    Aditya Patwardhan (@adityapatwardhan) We are also seeing this issue. Any luck with a timeline on this?

  12. dkattan commented on Jan 24, 2023

    @dkattan
    Contributor
  13. ghost added
    In-PRIndicates that a PR is out for the issue
    on Jan 25, 2023
  14. dkattan commented on Jan 25, 2023

    @dkattan
    Contributor

    Aditya Patwardhan (@adityapatwardhan) Can you look at my merge request and perhaps test it since you have access to the required DevOps environment? #19033

  15. adityapatwardhan commented on Mar 9, 2023

    @adityapatwardhan
    Member

    This PR should fix the problem: #19302

    We plan to release the next PowerShell Preview with this change.

  16. dkattan commented on Mar 10, 2023

    @dkattan
    Contributor

    This PR should fix the problem: #19302

    We plan to release the next PowerShell Preview with this change.

    Yaaass. While you’re in there, any love for SourceLink or Debug symbols? 🥺

  17. adityapatwardhan commented on Mar 13, 2023

    @adityapatwardhan
    Member

    Not right now at least. But maybe in a separate PR.

  18. dkattan commented on Mar 13, 2023

    @dkattan
    Contributor

    Not right now at least. But maybe in a separate PR.

    Like perhaps this one you created 5 years ago?

    #8184

  19. ghost removed
    In-PRIndicates that a PR is out for the issue
    on Mar 14, 2023
  20. adityapatwardhan commented on Mar 14, 2023

    @adityapatwardhan
    Member

    Darren Kattan (@dkattan) The Microsoft.PowerShell.SDK version v7.4.0-preview.2 will be available on NuGet.org in sometime. Could you please help validate that your scenario is fixed by that?

  21. dkattan commented on Mar 15, 2023

    @dkattan
    Contributor

    Darren Kattan (@dkattan) The Microsoft.PowerShell.SDK version v7.4.0-preview.2 will be available on NuGet.org in sometime. Could you please help validate that your scenario is fixed by that?

    I'm trying but I'm not yet seeing it in nuget.

  22. dkattan commented on Mar 16, 2023

    @dkattan
    Contributor

    Darren Kattan (@dkattan) The Microsoft.PowerShell.SDK version v7.4.0-preview.2 will be available on NuGet.org in sometime. Could you please help validate that your scenario is fixed by that?

    I'm trying but I'm not yet seeing it in nuget.

    I found it, I didn't have the Include Prerelease box checked.

    Evidently it requires .NET 8 which requires Visual Studio 2022 17.6 Preview. Got all that installed.

    When I attempt to install Microsoft.PowerShell.SDK or Microsoft.PowerShell.Commands.Utility I get:

    Severity	Code	Description	Project	File	Line	Suppression State
    Error	NU1102	Unable to find package Microsoft.CodeAnalysis.CSharp with version (>= 4.6.0-2.23152.6)
      - Found 142 version(s) in nuget.org [ Nearest version: 4.6.0-1.final ]
      - Found 0 version(s) in Microsoft Visual Studio Offline Packages	TestPowerShell73Dependency2	C:\Users\DKattan\source\repos\TestPowerShell73Dependency2\TestPowerShell73Dependency2\TestPowerShell73Dependency2.csproj	1	
    

    System.Management.Automation, Microsoft.PowerShell.Commands.Diagnostics and Microsoft.PowerShell.Commands.Management install fine.

    Installing Microsoft.PowerShell.Commands.Management 7.4.0-preview.2 does solve the problem for TestPathCommand.

  23. adityapatwardhan commented on Apr 18, 2023

    @adityapatwardhan
    Member

    The was fixed by #19302 and should be available on the latest versions of v7.2, v7.3 and v7.4.0-preview.X

    Please re-open if you still see the issue.

  24. ghost removed
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Apr 18, 2023
  25. dkattan commented on Jun 15, 2023

    @dkattan
    Contributor

    The was fixed by #19302 and should be available on the latest versions of v7.2, v7.3 and v7.4.0-preview.X

    Please re-open if you still see the issue.

    Nuget package microsoft.powershell.sdk 7.3.4 is including refs to 7.3.3 causing my project to not build

    image

    This appears to be fixed in 7.4.0-preview.3 but we aren't on .net 8 yet, can we get this backported?

    image

  26. dkattan commented on Jun 15, 2023

    @dkattan
    Contributor

    The was fixed by #19302 and should be available on the latest versions of v7.2, v7.3 and v7.4.0-preview.X
    Please re-open if you still see the issue.

    Nuget package microsoft.powershell.sdk 7.3.4 is including refs to 7.3.3 causing my project to not build

    image

    This appears to be fixed in 7.4.0-preview.3 but we aren't on .net 8 yet, can we get this backported?

    image

    Turns out the version mismatch was not actually causing a problem.

    The full error was a BadImageFormatException from ReinforcedTypings

    Reinforced.Typings : Assembly loading warning RT0014: Assembly Microsoft.PowerShell.Commands.Utility (from C:\Users\DKattan\.nuget\packages\microsoft.powershell.sdk\7.3.4\ref\net7.0\Microsoft.PowerShell.Commands.Utility.dll) failed to load: System.BadImageFormatException: Could not load file or assembly 'Microsoft.PowerShell.Commands.Utility, Version=7.3.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Reference assemblies cannot be loaded for execution. (0x80131058)
    
    Reinforced.Typings : Unexpected error RT0999: Could not load file or assembly 'Microsoft.PowerShell.Commands.Utility, Version=7.3.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
    

    This was not preventing the build from working, simply preventing our TypeScript from being generated post build.

    I believe this would have actually been an error in 7.4 had I actually upgraded our project.

    ReinforcedTypings has some known issues with reference packages but I was able to workaround it by adding Microsoft.PowerShell.Commands.Utility and System.Management.Automation nuget packages to the project containing Reinforced Typings, generating path property to them and then referencing that in the ReinforcedTypings.Config.xml so it could find the unix/win (non-reference) assembly.

    No action necessary.

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

Metadata

Metadata

Labels

WG-DevEx-SDKhosting PowerShell as a runtime, PowerShell's APIs, PowerShell Standard, or development of modules

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions