Thats right I said it. I know we have been using the packages config for a long time. But there is a new sheriff in town and its name is project PackageReference.
There was a discussion on Sitecore Slack a few months ago where it was asked how people felt about the possibility of removing the NoReference NuGet packages for Sitecore. If you don't know what NoReference packages are, they are NuGet packages that isolate a single dll in NuGet.
These NoReference dlls are really important because they make upgrading really easy (allows you upgrade 1 dll at a time or all at once with NuGet upgrade command) and allows you to ignore all the pesky dependancies like NewtonSoft, etc... Basically it puts your project dependancies in your hands.
I was making a blog post and a video the other day about installing Sitecore home demo for Sitecore 9.1 and I noticed an interesting thing in the projects. No more NuGet packages.config files in the solution. All the NuGet references had been moved into the project. See this project file.
#1 this is REALLY tidy and clean. This also seems like it is going to be the new recommended way of referencing Sitecore dlls from NuGet. This is going to allow Sitecore to build all of its dlls independent from each other. Not being locked into a version 9.0.2 for all dlls in the deployment. But allowing them to build an analytics dll as version 12.0.0r00512 and the kernel as 12.0.0r00541. Sitecore will only have to provide the dlls in large packages like Sitecore or Sitecore Analytics. Then you to pick and choose your dlls from the Sitecore packages without the requirement No Reference packages. And as a developer you can choose the dlls you want and ignore all dependancies by setting PrivateAssets equal to none.
<PackageReference Include="Sitecore.Kernel" Version="9.0.180604"> <PrivateAssets>none</PrivateAssets> </PackageReference>
So what does packages references do that is different than normal NuGet packages?
No more restoring NuGet packages. When you build the project, it checks the referenced packages and makes sure they are there.
No more using package manager to upgrade your packages. Yup, its as simple as you think. Update the version in your project reference, reload the project and build. Poof upgraded. Mic drop.
Quickly be able to new up a project with the proper references. Instead of opening up the NuGet manager or having package console commands, to add dlls to your project. Just have a code snippet for your project. Need a Sitecore MVC project? Just add this to the csproj file:
Simple as that.
How about build configuration based NuGet references? You can use when clauses to determine the proper references to use. Isn't that slick.
Keep it tidy. Instead of using the packages.config to reference the NuGet dll and then referencing that dll in the project. Just do it all in one step now.
Instead of this:
Now you just add 1 line.
See more cool things you can do here.