1 00:00:07,230 --> 00:00:07,680 Hello. 2 00:00:08,430 --> 00:00:16,680 In this video, we're going to talk about Question 47, what are Nuggets packages look at is a Microsoft 3 00:00:16,680 --> 00:00:24,750 supported package manager, so a tool with which developers can create, share and consume useful code. 4 00:00:25,170 --> 00:00:31,510 There are tons of libraries that other developers created, which we can use in our own projects. 5 00:00:31,980 --> 00:00:35,940 Look at package manager is the tool that allows us to access them. 6 00:00:36,510 --> 00:00:41,850 Each package contains the yellow's built from the code that someone else developed. 7 00:00:42,300 --> 00:00:49,680 For instance, let's add another unit and walk to this project, and the unit is one of the most popular 8 00:00:49,710 --> 00:00:55,880 unit testing frameworks for C-sharp, and Mock is unlocking library together. 9 00:00:55,920 --> 00:01:01,290 There are two essential tools that we can use to create unique tests for our code. 10 00:01:01,830 --> 00:01:06,990 The easiest way to install a no-good package is by right clicking on the project. 11 00:01:08,280 --> 00:01:10,920 And selecting Manage to get packages. 12 00:01:12,970 --> 00:01:17,140 On this screen, we can search for the package that we want to install. 13 00:01:21,280 --> 00:01:24,700 After selecting it, we can choose the version that we want. 14 00:01:26,320 --> 00:01:30,880 Let's select the latest one and now we can click install. 15 00:01:35,380 --> 00:01:38,800 After installing the package, we can start using it. 16 00:01:46,340 --> 00:01:51,500 There is another, sometimes even more convenient way of installing nugget packages. 17 00:01:51,920 --> 00:01:55,100 We can simply start using the types from the package. 18 00:01:59,120 --> 00:02:05,060 No Visual Studio complains that it doesn't know this type, but we can choose to install this package 19 00:02:05,060 --> 00:02:06,290 from the context menu. 20 00:02:13,620 --> 00:02:16,260 And now the court compiles correctly. 21 00:02:16,890 --> 00:02:23,520 Now let's take a look at how this year's profile changed after installing those two packages to see 22 00:02:23,520 --> 00:02:25,710 the Sears profile of the project. 23 00:02:25,860 --> 00:02:27,540 We must first unload it. 24 00:02:28,320 --> 00:02:30,600 We can simply right click on the project. 25 00:02:31,790 --> 00:02:33,710 And select download project. 26 00:02:35,790 --> 00:02:39,720 And now we can select Edit Project File. 27 00:02:41,280 --> 00:02:45,930 And here we can see the entries that have been added by Nuggets package manager. 28 00:02:46,470 --> 00:02:50,730 The question is where exactly did the packages get installed? 29 00:02:51,330 --> 00:02:57,640 Well, this evolved with the versions of dotNet, but in net six, which we use in this course, it 30 00:02:57,660 --> 00:03:00,630 by default gets installed in your users folder. 31 00:03:00,810 --> 00:03:03,210 For example, in a path like this. 32 00:03:04,280 --> 00:03:07,100 Let's go to this folder and see the packages. 33 00:03:08,720 --> 00:03:09,440 Here it is. 34 00:03:09,770 --> 00:03:11,000 Let's take a look inside. 35 00:03:13,920 --> 00:03:19,620 And here we can see the onion folder that God created when the package was installed. 36 00:03:20,190 --> 00:03:23,970 Don't worry if for you, this entire folder looks different. 37 00:03:24,210 --> 00:03:30,580 I have dozens of different coding projects on my computer and overall four hundred and eight get the 38 00:03:30,600 --> 00:03:36,480 packages installed, thanks to the fact that the package gets installed in the user folder. 39 00:03:36,630 --> 00:03:39,180 It can be reused between different projects. 40 00:03:39,810 --> 00:03:46,830 I have multiple products using the unit, but this library only exists in a single copy on my machine. 41 00:03:46,980 --> 00:03:50,820 And for each of my projects, it gets taken from this folder. 42 00:03:51,300 --> 00:03:55,500 Let's take a look inside to see what's inside such a new package. 43 00:03:59,080 --> 00:04:02,290 In here, what is most important is the leap for the. 44 00:04:05,180 --> 00:04:10,520 In here, we can see the actual deals that get referenced from our project. 45 00:04:10,880 --> 00:04:13,100 Now I will do something, I mean. 46 00:04:14,690 --> 00:04:18,890 I will remove the entire immunity folder from this directory. 47 00:04:23,220 --> 00:04:30,180 Let's go back to Visual Studio and see if the project was built correctly after all the dials it needs 48 00:04:30,360 --> 00:04:31,500 have been deleted. 49 00:04:37,930 --> 00:04:39,880 Well, that's a bit surprising. 50 00:04:40,300 --> 00:04:44,000 The dude was successful and you think and you unit still works. 51 00:04:44,710 --> 00:04:48,160 Let's take a look again into the new Get Packages directory. 52 00:04:49,950 --> 00:04:54,030 It seems like the unit folder has magically reappeared. 53 00:04:54,690 --> 00:04:56,490 Actually, it's no wonder, Jake. 54 00:04:58,020 --> 00:05:02,610 This year's profile now clearly declares what packages it needs. 55 00:05:03,000 --> 00:05:09,330 Visual Studio notes that if the package is missing from the packages folder, it must simply reinstall 56 00:05:09,330 --> 00:05:09,720 it. 57 00:05:10,230 --> 00:05:15,360 It's quite convenient, especially if we share the code via some kind of repository. 58 00:05:15,780 --> 00:05:22,920 We only commit the code and package references to the repository, but not the packages themselves once 59 00:05:22,920 --> 00:05:26,010 another programmer downloads the code and builds it. 60 00:05:26,220 --> 00:05:30,390 The packages get installed on his or her machine automatically. 61 00:05:31,110 --> 00:05:32,070 One more thing? 62 00:05:32,460 --> 00:05:38,220 Sometimes Visual Studio messes something up, and it's not able to restore the packages. 63 00:05:38,520 --> 00:05:42,330 If this happens, we can restore them manually to do it. 64 00:05:42,360 --> 00:05:43,980 We must select tools. 65 00:05:46,760 --> 00:05:53,920 Nugget, package manager, package manager, console, and from this console, we must run those not 66 00:05:53,940 --> 00:05:58,820 restore command, which will restore all packages referenced in the solution. 67 00:06:03,760 --> 00:06:04,490 All right. 68 00:06:04,870 --> 00:06:08,950 We now know how to use the packages that someone else created. 69 00:06:09,370 --> 00:06:16,150 I highly recommend you use this beautiful concept and not reinvent the wheel each time you need something 70 00:06:16,150 --> 00:06:22,570 done in general when you think of something not specific to your project, but rather something that 71 00:06:22,570 --> 00:06:25,210 could likely be used by other developers. 72 00:06:25,450 --> 00:06:30,580 There is a 99 percent chance there is a new gift package that already does that. 73 00:06:31,240 --> 00:06:37,360 If you have some good ideas of your own, you can always create and publish your own nugget packages. 74 00:06:37,750 --> 00:06:42,940 In the document attached to this lecture, I linked a series of articles about that. 75 00:06:43,480 --> 00:06:44,200 All right. 76 00:06:44,500 --> 00:06:45,820 That's it in this lecture. 77 00:06:46,120 --> 00:06:49,000 Thanks for watching and see you in the next video.