-
Notifications
You must be signed in to change notification settings - Fork 262
Description
NuGet Product(s) Involved
NuGet.exe, dotnet.exe, MSBuild.exe
The Elevator Pitch
If you use a mono repo or a small list of separately built components, most CPM benefits are more or less lost on you - a few just allow some easy syncing, but you're likely just making sure to manually control the Directory.Packages.props file on a parent folder where all builds occur.
In a complicated web of interdependent components, however, CPM is much better. Previously, dependency versions of packages between these dependencies (for both third party stuff and also other dependent components) have to be manually tracked and this can quickly become cumbersome. Enter CPM - a magical way to try to instead manage Directory.Package.props file(s) and use them when you need them. Want to chain updates through everything for a product release? Just update this shared file and rebuild through the ripple!
The problem here is that I'm relying on windows files paths and copying a file in at pre-restore time / pipeline build time. This doesn't seem to flow with how the capability is supposed to be so seamless. I either have to have some kind of build/restore event that relies on the repository being pulled (shared repository where the Directory.Packages.props files live), and executes before both a local and pipeline build. I think the Microsoft.Build.CentralPackageVersion functionality of CentralPackagesFile - an msbuild property that allowed an override to default checking of the file in the folder - would be a useful alternative to having to invoke file I/O. I much rather would have a file read from its current location than manually copy it into every solution/project that needs it.
Thoughts?
Additional Context and Details
My CPM script examples for local development:
<!-- Creates a link from DestinationFolder to FullPath or copies if the link cannot be made. -->
<Target Name="CopyCPMFile" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(CI_BUILD)' != 'True'">
<Copy UseHardLinksIfPossible="true"
SourceFiles="%(CopyCPMFile.FullPath)"
DestinationFolder="%(CopyCPMFile.DestinationFolder)"
ContinueOnError="false"
SkipUnchangedFiles="true"/>
</Target>
<ItemGroup>
<CopyCPMFile Include="$(SolutionDir)..\CPMFiles\net471\Latest\Directory.Packages.props">
<DestinationFolder>$(ProjectDir)</DestinationFolder>
</CopyCPMFile>
</ItemGroup>