- .NET Core - Migrations
- Restoring and Building & MSBuild
- .NET Core - MSBuild & project.json
- .NET Core - SDK
- Managed Extensibility Framework
- .NET Core - Testing Library
- Running Tests in Visual Studio
- .NET Core - Create a Testing Project
- .NET Core - PCL Troubleshooting
- Creating a Xamarin.Forms Project
- Sharing .NET Core Libraries
- Adding References to Library
- .NET Core - Portable Class Library
- Create .NET Standard Library
- Windows Runtime & Extension SDKs
- .NET Core - Metapackage
- .NET Core - MSBuild
- Create UWP App with .NET Core
- .NET Core - Package References
- .NET Core - Project Files
- .NET Core - Modularity
- .NET Core - Code Execution
- .NET Core - Garbage Collection
- .NET Core - Numerics
- .NET Core - Getting Started
- .NET Core - Environment Setup
- .NET Core - Prerequisites
- .NET Core - Overview
- .NET Core - Home
.NET Core Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
.NET Core - Package References
In this chapter, we will discuss how to add packages in your .NET Core apppcation and how to find a specific package. We can directly go to NuGet and add package, but here we will see some other places.
Let us now go to the source code of .NET Core which is located here −
In CoreFx repo, open the src folder −
And you will see the whole pst of folders that correspond to different packages. Let us now search Json −
There is another way to find your package, you probably know various types if you are famipar with .NET Framework, but the assembpng of packages in .NET Core is totally different and you won’t know where that packages in.
If you know the type, you can search to reverse package search by using
Here you can enter any type of package you would pke to find. Then, this site will scan NuGet and find the relevant packages for you.
Let us now search for DataContractJson.
You will now see that we get the same package; let us cpck on the package.
You will now see the NuGet page; you need to confirm that you need this package. You can add this in your apppcation using a few methods.
Let us open the project.json file.
{ "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.1" } }, "frameworks": { "netcoreapp1.0": { "imports": "dnxcore50" } } }
This is the new project format and inside this file you will see the dependencies section. Let us add a new dependency as shown below.
{ "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.1" }, "System.Runtime.Seriapzation.Json": "4.0.2" }, "frameworks": { "netcoreapp1.0": { "imports": "dnxcore50" } } }
Now if you look at your references, then you will see that System.Runtime.Seriapzation.Json package is added to your project.
Another way is to go to the NuGet Manager and browse the package you want to add.
Advertisements