The Include attribute specifies the ID of the package to add to the project. The Version attribute specifies the version to get. Versions are specified as per NuGet version rules.
Use conditions to add a dependency that's available only in a specific target, as shown in the following example:
The dependency in the preceding example will only be valid if the build is happening for that given target. The $(TargetFramework) in the condition is an MSBuild property that's being set in the project. For most common .NET applications, you don't need to do this.
Add and remove dependencies
You can add and remove dependencies by editing your project file or through .NET CLI commands.
Edit the project file
To add a dependency, add a <PackageReference> item inside an <ItemGroup> element. You can add to an existing <ItemGroup> or create a new one.
Don't include inputs to the restore operation in the .targets or .props file of a referenced package. These inputs can include PackageReference items, ExcludeAssets attributes, the NuGet feeds to use, or other NuGet configuration. The .targets and .props files from packages aren't used until after NuGet restore is complete. Anything needed for restore needs to be in the project file or .targets file of the project itself, not a package dependency.
If you want to use ASP.NET APIs in a console application or class library, add a FrameworkReference item to your project file:
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.
.NET σχόλια
.NET είναι ένα έργο ανοιχτού κώδικα. Επιλέξτε μια σύνδεση για να παρέχετε σχόλια:
Συμμετάσχετε στη σειρά meetup για να δημιουργήσετε κλιμακούμενες λύσεις AI που βασίζονται σε πραγματικές περιπτώσεις χρήσης με συναδέλφους προγραμματιστές και ειδικούς.
Create a .NET project and learn to add packages and manage package dependencies in your project. Use the .NET Core CLI and NuGet registry to add libraries and tools to your C# applications through Visual Studio Code.