Skip to content

Hotfix/nuget packages - #19033

Closed
Darren Kattan (dkattan) wants to merge 2 commits into
PowerShell:masterfrom
dkattan:hotfix/nuget-packages
Closed

Darren Kattan (dkattan) wants to merge 2 commits into
PowerShell:masterfrom
dkattan:hotfix/nuget-packages

Conversation

@dkattan

Copy link
Copy Markdown
Contributor

PR Summary

Should fix #16862

Microsoft.PowerShell.SDK is missing references to

  • Microsoft.PowerShell.Commands.Management
  • Microsoft.PowerShell.Commands.Diagnostics
  • Microsoft.PowerShell.Security
  • Microsoft.WSMan.Management

This was OK because you could manually specify the a Reference via a HintPath but this workaround broke in 7.2 preview 7 due to this change: 046dec4#r98046816

Since then, it is literally impossible to reference types in any of those 4 libraries like ResolvePathCommand among dozens of others.

The only way I was able to work around this was by using a hex editor to modify the Microsoft.PowerShell.Commands.Management.DLL file to reference System.Management.Automation 7.X.X.0 instead of 7.X.X.500

Additionally, added symbols to the nuget packages so SourceLink could work which will help app developers using the PowerShell SDK tremendously.

This change should not have any negative consequences as the nuget packages are unusable anyway, however I don't have a great way to test this as the devops pipeline only works in the Microsoft DevOps environment.

PR Context

PR Checklist

@pull-request-quantifier-deprecated

Copy link
Copy Markdown

This PR has 16 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Extra Small
Size       : +14 -2
Percentile : 6.4%

Total files changed: 3

Change summary by file extension:
.ps1 : +1 -0
.psm1 : +12 -1
.yml : +1 -1

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@dkattan

Copy link
Copy Markdown
Contributor Author

Travis Plunk (@TravisEz13) Can you take a look at this and let me know what you think?

@TravisEz13

Copy link
Copy Markdown
Member

Aditya Patwardhan (@adityapatwardhan) Can you review?

PackageVersion = $Version
PackageRuntime = $Runtime
PackageConfiguration = $Configuration
IncludeSymbols = $IncludeSymbols

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert this. This is just a test file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But shouldn't we also test this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is used only for testing the compiler. Please remove this.

@adityapatwardhan

Copy link
Copy Markdown
Member

I have some concerns about the size of the nuget packages with symbols added in.

I am starting a private build for the change to see if it fixes it. My hunch is that it would need some code to be added here:

function CleanupGeneratedSourceCode
{
param(
[string] $assemblyName,
[string] $generatedSource,
[string] $filteredSource
)
$patternsToRemove = @(
'[System.Management.Automation.ArgumentToEncodingTransformationAttribute]'
'typeof(System.Security.AccessControl.FileSecurity)'
'[System.Management.Automation.ArgumentTypeConverterAttribute'
'[System.Runtime.CompilerServices.IteratorStateMachineAttribute'
'[Microsoft.PowerShell.Commands.ArgumentToModuleTransformationAttribute]'
'[Microsoft.PowerShell.Commands.SetStrictModeCommand.ArgumentToVersionTransformationAttribute]'
'[Microsoft.PowerShell.Commands.SetStrictModeCommand.ValidateVersionAttribute]'
'[System.Management.Automation.OutputTypeAttribute(typeof(System.Management.Automation.PSRemotingJob))]'
'typeof(System.Management.Automation.LanguagePrimitives.EnumMultipleTypeConverter)'
'[System.Management.Automation.Internal.CommonParameters.ValidateVariableName]'
'[System.Management.Automation.ArgumentEncodingCompletionsAttribute]'
'[Microsoft.PowerShell.Commands.AddMemberCommand'
'[System.Management.Automation.ArgumentCompleterAttribute(typeof(Microsoft.PowerShell.Commands.Utility.JoinItemCompleter))]'
'[System.Management.Automation.ArgumentCompleterAttribute(typeof(System.Management.Automation.PropertyNameCompleter))]'
'[Microsoft.PowerShell.Commands.ArgumentToTypeNameTransformationAttribute]'
'[System.Management.Automation.Internal.ArchitectureSensitiveAttribute]'
'[Microsoft.PowerShell.Commands.SelectStringCommand.FileinfoToStringAttribute]'
'[System.Runtime.CompilerServices.IsReadOnlyAttribute]'
'[System.Runtime.CompilerServices.NullableContextAttribute('
'[System.Runtime.CompilerServices.NullableAttribute((byte)0)]'
'[System.Runtime.CompilerServices.NullableAttribute(new byte[]{ (byte)2, (byte)1, (byte)1})]'
'[System.Runtime.CompilerServices.AsyncStateMachineAttribute'
'[Microsoft.PowerShell.Commands.SetStrictModeCommand.ArgumentToPSVersionTransformationAttribute]'
'[Microsoft.PowerShell.Commands.HttpVersionCompletionsAttribute]'
'[System.Management.Automation.ArgumentToVersionTransformationAttribute]'
'[Microsoft.PowerShell.Commands.InvokeCommandCommand.ArgumentToPSVersionTransformationAttribute]'
'[Microsoft.PowerShell.Commands.InvokeCommandCommand.ValidateVersionAttribute]',
'[System.Management.Automation.OutputTypeAttribute(new System.Type[]{ typeof(Microsoft.PowerShell.Commands.Internal.Format.FormatStartData), typeof(Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData), typeof(Microsoft.PowerShell.Commands.Internal.Format.FormatEndData), typeof(Microsoft.PowerShell.Commands.Internal.Format.GroupStartData), typeof(Microsoft.PowerShell.Commands.Internal.Format.GroupEndData)})]'
)
$patternsToReplace = @(
@{
ApplyTo = @("Microsoft.PowerShell.Commands.Utility")
Pattern = "[System.Runtime.CompilerServices.IsReadOnlyAttribute]ref Microsoft.PowerShell.Commands.JsonObject.ConvertToJsonContext"
Replacement = "in Microsoft.PowerShell.Commands.JsonObject.ConvertToJsonContext"
},
@{
ApplyTo = @("Microsoft.PowerShell.Commands.Utility")
Pattern = "public partial struct ConvertToJsonContext"
Replacement = "public readonly struct ConvertToJsonContext"
},
@{
ApplyTo = @("Microsoft.PowerShell.Commands.Utility")
Pattern = "Unable to resolve assembly 'Assembly(Name=Newtonsoft.Json"
Replacement = "// Unable to resolve assembly 'Assembly(Name=Newtonsoft.Json"
},
@{
ApplyTo = @("System.Management.Automation")
Pattern = "Unable to resolve assembly 'Assembly(Name=System.Security.Principal.Windows"
Replacement = "// Unable to resolve assembly 'Assembly(Name=System.Security.Principal.Windows"
},
@{
ApplyTo = @("System.Management.Automation")
Pattern = "Unable to resolve assembly 'Assembly(Name=Microsoft.Management.Infrastructure"
Replacement = "// Unable to resolve assembly 'Assembly(Name=Microsoft.Management.Infrastructure"
},
@{
ApplyTo = @("System.Management.Automation")
Pattern = "Unable to resolve assembly 'Assembly(Name=System.Security.AccessControl"
Replacement = "// Unable to resolve assembly 'Assembly(Name=System.Security.AccessControl"
},
@{
ApplyTo = @("System.Management.Automation")
Pattern = "[System.Runtime.CompilerServices.NullableAttribute(new byte[]{ (byte)1, (byte)2, (byte)1})]"
Replacement = "/* [System.Runtime.CompilerServices.NullableAttribute(new byte[]{ (byte)1, (byte)2, (byte)1})] */ "
},
@{
ApplyTo = @("System.Management.Automation")
Pattern = "[System.Runtime.CompilerServices.NullableAttribute(new byte[]{ (byte)2, (byte)1})]"
Replacement = "/* [System.Runtime.CompilerServices.NullableAttribute(new byte[]{ (byte)2, (byte)1})] */ "
},
@{
ApplyTo = @("System.Management.Automation")
Pattern = "[System.Runtime.CompilerServices.CompilerGeneratedAttribute, System.Runtime.CompilerServices.NullableContextAttribute((byte)2)]"

@ghost ghost added the Review - Needed The PR is being reviewed label Feb 9, 2023
@ghost

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@daxian-dbw

Copy link
Copy Markdown
Member

Closing this PR as Aditya Patwardhan (@adityapatwardhan) is actively working on a solution to this issue.

@ghost ghost removed the Review - Needed The PR is being reviewed label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestPathCommand and several others removed in PowerShell 7.2 SDK

5 participants