This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Package Management with NuGet!
You have completed Package Management with NuGet!
Preview
How to use NuGet and semantic versioning keep dependencies up to date.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You may have noticed this number
up here by the word Updates.
0:00
This is the number of packages
in our project that aren't
0:03
updated to the latest version.
0:06
All of these packages were installed
when we created the ASP.NET MVC project.
0:08
So you might be wondering why it
didn't install the latest version.
0:13
Could it be that ASP.NET MVC won't
work with the latest versions?
0:17
ASP.NET MVC can work with
the latest versions of most,
0:22
actually I think all of these packages.
0:26
The reason the latest version wasn't
installed is because the ASP.ET MVC
0:29
project template was created a while ago.
0:33
And most of these libraries have
released newer versions sense then.
0:36
Looking through them, it looks like
they're all pretty common libraries and
0:40
are probably all using
semantic versioning.
0:44
So we can tell if we can safely update
them by looking at their version numbers.
0:47
Remember only a change to the major
version number means it might contain some
0:52
breaking changes.
0:56
Updating the library to a higher or
0:57
lower major version than the one we're
already using, may break our software.
0:59
The safest bet is to update these all
to the latest patch version number.
1:04
But updating them to the latest minor
version number is reasonably safe too.
1:09
Here's something to be aware of
when updating multiple packages.
1:13
If I were to click Select all packages and
1:17
then click Update, it would update all
of these packages to the latest version.
1:20
That's the version shown here
under the current version number.
1:26
Looking at Newtonsoft.Json,
1:31
this means we'd be updating from major
version six to major version eight.
1:33
That's a big jump.
1:39
The only other package where the major
version numbers don't match is jQuery.
1:40
Here we'd be going from
jQuery1 to jQuery2.
1:45
With everything else only the minor and
patched version numbers change.
1:50
Let's uncheck Json and
jQuery and click Update.
1:54
We can double check what we're doing in
the confirmation dialog that pops up, and
2:03
then agree to the licenses.
2:07
For now we can ignore this error about
Visual Studio needing to restart.
2:12
This is a temporary issue with
the Microsoft.net.compilers package.
2:17
Now everything is updated to
latest except for jQuery and Json.
2:22
What about these two?
2:28
It's times like these that we really need
to know about the libraries we're using.
2:29
Well it's always good to have a reasonable
knowledge about the libraries we're using.
2:33
Let's click on jQuery and
then look at its version history.
2:37
Let's take a look at the details for
the first release of jQuery 2.
2:44
Wow, it says here that it was
released way back in 2013.
2:51
That's a full three years prior to
the time this workshop was recorded.
2:56
Now we need to figure out why Microsoft
decided to have ASP.NET MVC use
3:00
version one of the library instead
of the latest and greatest.
3:04
If we looked at the release notes for
jQuery 2,
3:08
we'd learn that it doesn't support version
eight or earlier of Internet Explorer.
3:11
That's why the major version
number of jQuery was
3:15
changed when it released jQuery 2.
3:18
Internet Explorer 8 is a pretty
old web browser by now and
3:20
I doubt the people using this
Web app will be using it.
3:24
So I think it's safe to update
this one to the latest.
3:27
Now for Json.
3:31
Honestly I don't know why Microsoft
wants to use version six.
3:33
Version seven was released
nearly a year ago.
3:37
I'll update this to the latest as well,
but
3:43
I'll be taking a risk that
something will break in my app.
3:45
Updating a library might cause
my project's build to fail.
3:50
Or worse, it might cause a latent bug
that won't be discovered until runtime.
3:54
This is one of the reasons why vigilant
developers write good unit test and
3:59
test their code before and
4:03
after making big changes like updating
the versions of the libraries.
4:04
If we find that an updated
package causes some issues,
4:08
we can always revert back by updating
to a previous version of the package.
4:11
The other way we could have updated all of
these packages to the latest minor version
4:15
is to use NuGet's Package Manager Console.
4:19
We can open the console
by clicking Tools >
4:23
NuGet Package Manager >
Package Manager Console.
4:25
Anything we can do in the NuGet
graphical user interface
4:28
we can do with the console, and more.
4:32
I've included a link to information on
how to use the console in the teacher's
4:34
notes of this workshop.
4:38
Also any command line tools that come
in NuGet packages can be run here.
4:39
For example, we can run Entity Framework's
migrate command from here because it's in
4:43
the tools directory of
the Entity Framework package.
4:47
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up