NuGet Central Package Management Is AWSOME! .NET Global Packages & Versions Simplified
Ғылым және технология
NuGet is essential for any and all .NET applications, but tracking versions, adding references, and ensuring everything is kept up to date can be a pain in large applications. Well Central Package Management is here introducing simplified version controls and even the ability to add global packages from a single location. You have to check this out.
Links:
Docs: learn.microsoft.com/nuget/con...
.NET MAUI Specifics: github.com/dotnet/maui/tree/m...
Chatpers:
00:00 - Intro
01:51 - Enabling Central Package Management
05:00 - Managing Versions Centrally
07:55 - Global NuGet Package References
09:28 - Wrap-up
Join this channel to get access to perks:
/ @jamesmontemagno
👕 Buy some swag! - jamesmontemagno.myspreadshop....
☕️ Buy me a coffee - www.buymeacoffee.com/jamesmon...
Follow:
👨💻 GitHub: github.com/jamesmontemagno
🦜 Twitter: / jamesmontemagno
📄 Website: www.montemagno.com
📰 Newsletter: newsletter.montemagno.com/
Disclaimer: This channel, videos, and streams are created in my spare time and are a product of me... James Montemagno! They are NOT officially affiliated or endorsed by Microsoft (my employer) in any way. Opinions and views are my own.
What is on my hat? It is the CLE clothing logo because I am from Cleveland! Checkout their awesome CLE merch: cleclothingco.myshopify.com/
What is that art on my wall? It is an original piece from the French street artist Gregos of La Butte Montmartre: / bcez1onhiqx
My Setup:
📷 Canon M50 Mark II - amzn.to/3P8R7lp
💡 Nanoleaf Elements Lights - amzn.to/3umwJVW
🎙 Blue Spark Microphone - amzn.to/3qgtYkq
🎙 Blue Pop Filter - amzn.to/3jEWM3r
🤳 Rode Microphone Arm - amzn.to/2Z68AlE
🎧 Sony MDR7306 Headphones - amzn.to/372jxta
📲 Stream Deck - amzn.to/373Uk1n
🖱 MX Master 2S Mouse - amzn.to/3d7J2gj
⌨️ Tecware Phantom Keyboard - amzn.to/3aUP4y9
#dotnet #nuget #visualstudio #dotnetmaui
Пікірлер: 46
This really makes massive projects so much easier! Thank you.
Super!... Useful tips!
Great feature James. Will do it tomorrow on my projects😍
@JamesMontemagno
10 ай бұрын
Noice! let me know how it goes!!!!
I already knew about CPM, but not GlobalPackageReference. Thanks for sharing!
@JamesMontemagno
10 ай бұрын
Me either! so cool!
Awesome :o that is exactly what i need currently. Thanks a lot
I haven't seen this before. Thanks for the insight!
@JamesMontemagno
10 ай бұрын
Was new to me as well even though it has been out for a while. So many nice things... sometimes just discovering them is the problem lol.
I’ve learned something new. Thanks
Very useful video! Thanks!
@JamesMontemagno
9 ай бұрын
Glad it was helpful!
Seriously nice feature.
I'm not clear how any of this is better than right-clicking the solution and choosing Manage NuGet Packages for Solution and just letting it update all the packages itself. Does it speed up AZDO build pipelines or something? I guess as Microsoft pushes people away from Visual Studio and towards VSCode and the command line, this will come in handy. Especially on Mac. Maybe I answered my own question.
@haslamconsultancy2152
10 ай бұрын
I guess it can be for cleaner commits. Committing in a centralised place rather than across multiple project files but it's only a very small benefit. The 2nd part of having a global package just seems nice for cleanliness also
@JamesMontemagno
10 ай бұрын
That and also I think just managing everything in 1 place, no need to open every since csproj. Imagine super large projects, just saves time.
@almis6470
10 ай бұрын
@@JamesMontemagno but it's easier to manage nuget packages for solution using the GUI rather than adding manually the references in the props file so I'm not sure if you are saving time. It also means that I cannot use the GUI anymore to install new nugets right?
@NickSteffen
10 ай бұрын
@@almis6470 Yea, the bigger problem is that if someone doesn’t know this feature is being used and they’re used to looking at versions in the GUI, they are going to get confused real fast. The feature seems half baked because of this and may actually waste more time than it saves. You also have to wonder how committed Microsoft is in that case since they’ve disabled these type of half supported solution level flags and features in the past.
@grumpydeveloper69
9 ай бұрын
@@JamesMontemagno But we already have Consolidate on the Manage packages for SOlution tab for that as well
Does: dotnet add package Some.Package
So what is the added value of central package management vs. just pressing "Update" in IDE for solution?
🤯🤯🤯 👏👏👏
Is the nuget package manager taking into consideration the GlobalPackageReference when updating or adding a dependency so that it doesn't add the ref in the given project's csprojs ?
Great stuff! However, one question is coming to my mind...what if each project have different set of packages?
@JamesMontemagno
10 ай бұрын
That is what I showed first, you just don't specify a PackageReference per usual in the project. You just are centralizing all the versions. If ALL of your nugets are different in each project... then up to you if you want a more central place.
@ArkFen
10 ай бұрын
@@JamesMontemagno not very clear still... do you mean the moment you showed somthing with a star like 8.0.0-* ? or somethings else... if you mean the star, then do we set the Version attribute inside of the projects which use different versions? will system not give us error then? Actually I have all the versions same but I was curious as well and this comment brought my attention to it
@grumpydeveloper69
9 ай бұрын
@@JamesMontemagno So GlobalPackageReference is mostly useful for packages that will be in all you projects. If I have a solution with 60 projects I would not expect all of the to use FluentValidation. Does this Global reference mean the package is considered for compiling/linking your code, hence it is taken on a ride in building *all* you projects in that solution?
So the PackageVersion is maintained per solution? Or could I move it up even more. As you explained we have an applicaiton consisting of multiple solutions all generating different programe and we either use multiple solutions, or solution filters. Would you need to have the Directory.Packages.props file at the solution file level, of when I use diferent subfolder for different solutions I can put it in the repo root folder for instance.
@grumpydeveloper69
9 ай бұрын
Should have read the Docs, yes you can put these files up to the repo root for more global use.
PackageVersion is in essence replacing the Manage Packages for solution and then use the Consolidate option? You also did not show how you would then Update a package to a newer version, can I still go the any project and say Update to latest, and VS will default to updating the Directory.Packages.props instead of adding a version to that project. Or is this a manual editing task at this time?
Awesome video, so I subscribed first. But, reading the description, and finding out your a Clevelander!. Me too 😆👍!
How does it work with Maui app? Where can I remove versions for packages that are under platforms?
@JamesMontemagno
10 ай бұрын
I put a link in the video description on details. There is a lot of work in and around .NET 8 in RC2 for it
@zarkokomljenovic4865
10 ай бұрын
@@JamesMontemagno Yeah, it looked complicated 🫣 Thanks for your response!
You can`t use "*" in globally defined package version - Error NU1011 Centrally defined floating package versions are not allowed
Does this work with solutions with .NET Framework projects, or would they have to be upgraded to .NET 6?
@JamesMontemagno
9 ай бұрын
Need to use .NET 6+ and new project system
😊😊😊❤
Hey James, great video on! While I'm definitely a fan of managing packages at the solution level, I do have some reservations about the Global Reference feature. While it streamlines things, it seems a bit too broad for my liking. For example, it would be awesome if we could set Global References specific to types of projects, like Tests. I know we can achieve something similar with PackageReference, but the Global Reference feature seems like it might be a step too far in generalizing dependencies. Would love to know your thoughts on this or if there are workarounds to make Global Reference more nuanced. Keep up the good work!
@JamesMontemagno
10 ай бұрын
You could setup more specific rules: learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management#central-package-management-rules as an option. Based on how your items are setup
Wildcard package versioning is not supported. A big disadvantage. Once enabled, all package versions are to be defined only in this file. And only version # can only be overridden if necessary. Reference cannot be defined directly at the project level, even if needed in only one project. A cumbersome process. It should be rather a hierarchical definition.