Skip to content

Upgrade 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 #919

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 16 commits into from
Apr 5, 2018

Conversation

bergmeister
Copy link
Collaborator

@bergmeister bergmeister commented Mar 3, 2018

PR Summary

Closes #879

At the moment we use an unofficial package from Nuget.org, which is a self-contained version of System.Management.Automation (including dependencies) from 6.0.0-alpha13, which contains the Parser that PSSA uses.

For coreclr:

  • This required the upgrade from netstandard1.6 to netstandard2.0, which required some more NuGet packages: Microsoft.CSharp, Microsoft.Management.Infrastructure (for DSC rules, this is only available as a pre-release) and System.Reflection.TypeExtensions
  • I tested in on Windows (10) and a Ubuntu VM and I only had the same 9 local test failures that I currently also get for the development branch

For fullclr:

  • We are now using the reference assemblies instead. Because the rule UseIdenticalMandatoryParametersDSC compiles only in PSv4 I had to add a new PSV4Release build option.
  • In order to thoroughly test the fullclr change, I created 2 azure machines with WMF3 (WinServer2012) and WMF4 (WinServer2012R2) to run the test. The outcome was that for WMF3, the current release (or the development branch) have an awful lot (245) failures. This PR reduces it to only around 8, which is good and an improvement. For WMF4, there were no test failures for the development branch but 1 test in this PR. This test failure could be looked into but it seems to be minor because I can see from the test failure already that it is just a string that is slightly different (additional quote in an expected string) and therefore I think this might be negligible.

Old unused csproj files were also removed

The reason for the PowerShell Core Appveyor failure is because the Windows image is still using pwsh 6.0.0 but the system.management,automation reference is 6.0.2. I opened an issue at appveyor/ci#2230 and this will get fixed in the next 3 weeks, therefore a step was added to install pwsh 6.0.2 on the Windows image if necessary

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets. Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • [NA] User facing documentation needed
  • Change is not breaking: The test results on Ubuntu indicate breaking changes
  • [NA] Make sure you've added a new test if existing tests do not effectively test the code changed
  • This PR is ready to merge and is not 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

…h required upgrade from netstandard 1.6 to netstandard2.0,which included some breaking changes in netstandard2.0 that required some more nuget packges.
@@ -1141,7 +1141,7 @@ private List<ExternalRule> GetExternalRule(string[] moduleNames)
{
dynamic description = helpContent[0].Properties["Description"];

if (null != description && null != description.Value && description.Value.GetType().IsArray)
if (description != null && description.Value != null && description.Value.GetType().IsArray)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just to highlight why I needed the NuGet package for Microsoft.CSharp, which was included in netstandard1.6 but not netstandard2.0

Copy link
Contributor

Choose a reason for hiding this comment

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

yup - I found this as well when I was looking at building against PowerShellStandard.Library


<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Management.Automation" Version="6.0.1.1" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="1.0.0-alpha08" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a good example to show that the old System.Management.Automation package was self-contained and now we also need its other dependency Microsoft.Management.Infrastructure.

@iSazonov
Copy link

iSazonov commented Mar 5, 2018

I wonder - Could PSSA use current PowerShell installation? - there is SMA.dll with all dependencies.

@bergmeister
Copy link
Collaborator Author

@iSazonov Can you please clarify what you mean by PowerShell installation? The issue is that currently there is a missing feature in the PowerShell Parser and I expect the change to come in about 1 month and therefore want to consume the parser via the system.management.automation nuget package in order for the update to work on any old or even current version of PowerShell such as e.g. Windows PowerShell that will not receive the parser update in the near future.

@iSazonov
Copy link

iSazonov commented Mar 6, 2018

My quesion is could PSSA load needed dlls from c:\program file\powershell or C:\Windows\System32\WindowsPowerShell\v1.0?

@bergmeister
Copy link
Collaborator Author

It probably could but we don't wan't to. The whole point of this PR is being able to consume the latest version of system.management.automation with the latest required features of the parser.

@bergmeister bergmeister changed the title WIP: Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.1.1 from powershell-core feed, which requires upgrade to netstandard2.0 WIP: Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Mar 31, 2018
@bergmeister
Copy link
Collaborator Author

bergmeister commented Apr 3, 2018

The reason for the PowerShell Core Appveyor failure is because the Windows image is still using pwsh 6.0.0 but the system.management,automation reference is 6.0.1. I opened an issue at appveyor/ci#2230 and this will get fixed in the next 3 weeks, therefore it is probably best to disable the PowerShell Core build on Windows for the moment (the Ubuntu build should give us enough coverage in the meantime). Just using the 6.0.0 package instead is not a good either because the 6.0.0 package only works for netcore2.0 but only the 6.0.2 packages were fixed to work with netstandard2.0

…d by the new system.management.automation package.
@bergmeister bergmeister changed the title WIP: Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Apr 3, 2018
Copy link
Contributor

@JamesWTruher JamesWTruher left a comment

Choose a reason for hiding this comment

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

just one real question down below. Otherwise, this looks fine.

@@ -1141,7 +1141,7 @@ private List<ExternalRule> GetExternalRule(string[] moduleNames)
{
dynamic description = helpContent[0].Properties["Description"];

if (null != description && null != description.Value && description.Value.GetType().IsArray)
if (description != null && description.Value != null && description.Value.GetType().IsArray)
Copy link
Contributor

Choose a reason for hiding this comment

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

yup - I found this as well when I was looking at building against PowerShellStandard.Library


<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Management.Automation" Version="6.0.2" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="1.0.0-alpha08" />
Copy link
Contributor

Choose a reason for hiding this comment

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

could this just be Version="1.0.0-alpha* (that's what it is in PowerShell repo)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think it is reasonable to always take the latest version of a pre-release package.

</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<PackageReference Include="System.Management.Automation" Version="6.0.0-alpha13" />
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is really about full CLR should we still point at this? Would Microsoft.PowerShell.5.ReferenceAssemblies be better? (or Microsoft.PowerShell.3.ReferenceAssemblies) rather than pointing off to that alpha13 thing?

Copy link
Collaborator Author

@bergmeister bergmeister Apr 4, 2018

Choose a reason for hiding this comment

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

At the moment this PR changes it only for the coreclr but I can look into how to do it for full CLR. I first wanted to rather start with the simpler task but maybe it is better to do both in one go.

@bergmeister bergmeister changed the title Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 WIP Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Apr 4, 2018
@bergmeister bergmeister changed the title WIP Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Apr 4, 2018
@bergmeister bergmeister changed the title Upgrade unofficial 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Upgrade 'System.Automation.Management' NuGet package of version 6.0.0-alpha13 to official version 6.0.2 from powershell-core feed, which requires upgrade to netstandard2.0 Apr 4, 2018
@JamesWTruher
Copy link
Contributor

I think we're ready to go - go ahead and merge

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade from netstandard1.6 to netstandard2.0
3 participants