When I looked at the tutorials of MVC6, I get confused the usage of project.json. By my understanding this file is used to specify the project dependencies.
Prior to ASP.NET 5, we use nuget to manage the dependencies. But from some limited MVC6 samples I have seen I don't see people mention package.config
any more.
Please help me to understand:
nuget
to upgrade all depending components?project.json
manually?By my understanding [project.json] is used to specify the project dependencies.
Yes. One of the main functions of project.json
is to manage server-side dependencies. (It also specifies other project specific settings.) See the project.json file for more info.
Prior to ASP.NET 5, we use nuget to manage the dependencies.
Yes again. And, ASP.NET 5 still uses NuGet to manage dependencies. The configuration differs though. Instead of using packages.config
we use project.json
> dependencies
to list our project's NuGet packages (and other local dependencies.)
...from some limited MVC6 samples I have seen I don't see people mention package.config any more.
Yes again. Instead of package.config
, ASP.NET 5 lists all dependencies, including NuGet packages, within project.json
> dependencies
. These dependencies can be NuGet packages, local assemblies, or local projects.
To expand on this, in Visual Studio, the References folder is a reflection of our project.json
> dependencies
section. What we add to the one will appear in the other. See server-side dependency management.
In some ways, you can think of the References folder as a GUI view of project.json
> dependencies
. For instance, here is a dependencies
section from one of my projects alongside the References folder.
fx/
stuff that isn't in dependencies
).Do we still use nuget to upgrade all depending components?
Yes. We just use it differently. If we add a NuGet package to our project.json - either manually or via the GUI's package manager - then we will restore/update those using the NuGet feed.
Or [do] we have to modify the project.json manually?
No. You can modify project.json manually but there are two mains ways to add NuGet packages. Which you use is personal preference.
Importantly, what you do to via the GUI will be reflected in the project.json file, and what you do to project.json
> dependencies
will be reflected in the GUI.
Do we still use
nuget
to upgrade all depending components?
The short answer is yes.
We have to modify the project.json manually?
You could also do that.
You can really do anything you want:
You could use the nuget package manager UI.
You could use nuget CLI through the Package Manager Console
.
Or, you could even add, remove, change dependencies by modifying the project.json
which has a really nice auto-complete like in the Package Manager Console
.
The only difference now is that there isn't any mention of the installed packages in the project file (previously *.csproj
), so yo don't have to add the references manually like when we had the packages.config
.
Do we still use nuget to upgrade all depending components
No, you can just add them by your hand with the versions. Most of the IDEs and code editors has support for nuget dependency auto-complete inside project.json file.
More info on project.json file: https://github.com/aspnet/Home/wiki/Project.json-file (could be a little outdated).
More info on DNX dependencies: http://docs.asp.net/en/latest/dnx/overview.html?highlight=project#dependencies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With