-
Notifications
You must be signed in to change notification settings - Fork 198
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
Central package management (CPM) #188
Central package management (CPM) #188
Conversation
src/Directory.Build.props
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this file so that it's easy to tell the difference what CPM did to lock files.
<Project> | ||
<PropertyGroup> | ||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | ||
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're doing both CPM and transitive pinning here. See https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the Version
attribute from all PackageReference
items In all project files. There are only two project files of note: DistributedLock.ZooKeeper.csproj
and DistributedLockCodeGen.csproj
.
@@ -47,14 +47,6 @@ | |||
"System.IO.Hashing": "6.0.0" | |||
} | |||
}, | |||
"Microsoft.Bcl.AsyncInterfaces": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually confirmed that there is a corresponding NuGet package with type
CentralTransitive
here and elsewhere.
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" /> | ||
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" Condition="$(Configuration) == 'Release'"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question: do we need Condition
s like this? I got this from the corresponding project files.
Response from @madelson (copypasting from #186 (comment)):
Yes I don't want public api analysis in debug mode, because of the weird setup I have where internal methods in Core are public in debug mode. The reason for that is that it forces me to think explicitly about which Core methods are "internal APIs" exposed to all DL implementations and which ones are for use within Core only, but it plays havoc with the analyzer in debug mode.
@@ -1,5 +1,5 @@ | |||
{ | |||
"version": 1, | |||
"version": 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting that the version
changed from 1 to 2. Given that there is a new type
CentralTransitive
, I guess that makes sense.
<PackageReference Include="Moq" Version="4.13.1" /> | ||
<PackageReference Include="nunit" /> | ||
<PackageReference Include="nunit3testadapter" /> | ||
<PackageReference Include="Microsoft.NET.Test.SDK" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed tabs and spaces
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" /> | ||
<PackageReference Include="nunit" /> | ||
<PackageReference Include="NUnit3TestAdapter" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this used to have a different version than DistributedLock.Tests.csproj
. There is no VersionOverride
per this thread, but that means that there are extra diffs in the lock file.
<PackageReference Include="Nullable" Version="1.3.1"> | ||
<PackageReference Include="ZooKeeperNetEx" /> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" /> | ||
<PackageReference Include="Nullable" Condition="'$(TargetFramework)' != 'netstandard2.1'"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given <TargetFrameworks>netstandard2.0;netstandard2.1;net461</TargetFrameworks>
on line 4 of this file, I think it was an oversight that this Condition
didn't exist. Note that this change is reflected in the lock file diff:
c87fb79#diff-b74c05733e0ca95b4f1c079e5455270db5118c2ba952b1cbc46d7a1452a8fb18L175. (Reminder that netstandard2.1 uses C# 8 by default.)
Does it break without this condition? I would have thought the package just noops in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@madelson If you remove Condition only from ZooKeeper.csproj
, you get
DistributedLock\src\DistributedLock.ZooKeeper\DistributedLock.ZooKeeper.csproj : error NU1010: The PackageReference items Nullable do not have corresponding PackageVersion.
This makes sense because
ZooKeeper.csproj
targetsnetstandard2.1
Condition="'$(TargetFramework)' != 'netstandard2.1'"
exists forDirectory.Packages.props
- the version must always be specified in
Directory.Packages.props
, but in this case, the version is not specified forNullable
innetstandard2.1
It's okay to install Nullable
for netstandard2.1
here (or in other projects), but it's unnecessary.
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/> | ||
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" PrivateAssets="All" Condition="$(Configuration) == 'Release'"/> | ||
<Using Remove="System.Net.Http"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fly-by fix: removed this duplicate Using
item because it appears a few lines below.
@madelson Seems like there are some build errors:
Edit: just saw #189 |
src/Directory.Build.props
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open question: do you want to keep the lock files? My intention was that they will make this PR a lot more review-able, but I'm fine with not using them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to have them
This implements #179.
Turns out I couldn't reopen #186 because I did some force-pushes on git. Copypasted all comments so that reviewers won't have to go back and forth between two PRs.