Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Move to central package pinning #10716

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Move to central package pinning #10716

merged 2 commits into from
Aug 9, 2024

Conversation

jaredpar
Copy link
Member

@jaredpar jaredpar commented Aug 7, 2024

This should make it much easier for us to respond to CG alerts in the future. All that will need to be done is add an entry in Directory.Packages.props and it will automatically impact all consumers of it.

Consider this example in Roslyn for how to respond to a CG issue

dotnet/roslyn#74653

### Summary of the changes

Fixes:

This should make it much easier for us to respond to CG alerts in the
future. All that will need to be done is add an entry in
Directory.Packages.props and it will automatically impact all consumers
of it.

Consider this example in Roslyn for how to respond to a CG issue

dotnet/roslyn#74653
@jaredpar jaredpar requested a review from a team as a code owner August 7, 2024 18:13
@@ -21,6 +21,9 @@

<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Moq" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for my own understanding, why are these neccessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

I had the same question. Does arcade do something to these packages? Because it seems like the override version would otherwise always match the real version.

Copy link
Member

Choose a reason for hiding this comment

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

I assume it's because these projects depend on these packages implicitly, and if we didn't set the version explicitly here, they'd be set to the version in the root project, not the overridden version in the compiler projects.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is going on here is that there are three sources of two sources of references for MS.CA.CSharp (and the other projects):

  1. The project ref to Microsoft.CodeAnalysis.Razor.Compiler.csproj which uses version 4.9.2
  2. The project ref to Microsoft.AspNetCore.Razor.Test.Common.csproj which uses version 4.12.0-1.24379.11

Standard MSBuild logic will say the 4.12.0-1.24379.11 reference is higher therefore lets use that one. But in this case we're using central transitive pinning which means that the version in Directory.Packages.props wins over standard MSBuild logic. For this project it uses src\Compiler\Directory.Packages.props which has MS.CA.CSharp at 4.9.2. Without this VersionOverride we'd end up with un-runnable binaries.

The good news here is that an essential feature of central transitive package pinning is that it will warn aggressively on any silent downgrades like this. That is essential because central transitive pinning is somewhat spooky action at a distance. It's saying any transitive dependency that matches an entry in Directory.Packages.props will be done at the version specified in that file. Hence it aggressively warns if this ever results in a silent downgrade because that is almost certainly what you did not want.

That is exactly what happened here and why I was lead to make the correct override notations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the explanation. I didn't realise there still was a Directory.Packages.props in the Compiler folder, so I couldn't think of a place where a different version could possibly come from.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's still there because we haven't fully gotten the torn state solution into the .NET SDK. Once we get to say .NET 9 SDK RC1 we don't have to pin the compiler backwards any more and we can start undoing this nest of weirdness.

@@ -21,6 +21,9 @@

<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Moq" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" VersionOverride="$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I had the same question. Does arcade do something to these packages? Because it seems like the override version would otherwise always match the real version.

@jaredpar jaredpar merged commit cd1f82b into main Aug 9, 2024
12 checks passed
@jaredpar jaredpar deleted the dev/jaredpar/pin branch August 9, 2024 22:26
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Aug 9, 2024
333fred added a commit to 333fred/razor that referenced this pull request Aug 12, 2024
…enizer

* upstream/main: (53 commits)
  Move to central package pinning (dotnet#10716)
  Try to fix rename tests
  Unskip rename tests
  I spent 10 minutes looking up cool Mr Freeze catch phrases for this commit message, and I didn't like any of them.
  Clean up CompilationTagHelperResolver
  Clean up all ITagHelperDescriptorProviders a bit (and found a bug!)
  Make ExcludeHidden and IncludeDocumentation init-only properties
  Swap TagHelperDescriptorProviderContext.Create methods for constructors
  Remove TagHelperDescriptorProviderContext.Items property
  Make TargetSymbol a TagHelperDescriptorProviderContext property
  Make Compilation a TagHelperDescriptorProviderContext property
  Merge TagHelperDescriptorProviderContext and DefaultContext
  Don't pass code document and source text around in diagnostics translator, plus some cleanup
  Remove unnecessary parameter, because it can be trivially retrieved
  Find razor document correctly in RemoveDocumentMappingService
  Add extension methods that convert URIs to Roslyn file paths
  Use Uri.LocalPath rather than GetAbsoluteOrUNCPath()
  Move MapToHostDocuementUriAndRangeAsync to extension methods
  Fix small typo in comment
  Remove unused DocumentState method
  ...
@dibarbet dibarbet modified the milestones: Next, 17.12 P2 Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants