Įvykiai
03-17 21 - 03-21 10
Prisijunkite prie meetup serijos, kad sukurtumėte keičiamo dydžio DI sprendimus, pagrįstus realaus pasaulio naudojimo atvejais, su kolegomis kūrėjais ir ekspertais.
Registruotis dabarŠi naršyklė nebepalaikoma.
Atnaujinkite į „Microsoft Edge“, kad pasinaudotumėte naujausiomis funkcijomis, saugos naujinimais ir techniniu palaikymu.
This article explains how to add and remove package dependencies by editing the project file or by using the CLI.
The <PackageReference>
project file element has the following structure:
<PackageReference Include="PACKAGE_ID" Version="PACKAGE_VERSION" />
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:
<PackageReference Include="PACKAGE_ID" Version="PACKAGE_VERSION" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
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.
You can add and remove dependencies by editing your project file or through .NET CLI commands.
To add a dependency, add a <PackageReference>
item inside an <ItemGroup>
element. You can add to an existing <ItemGroup>
or create a new one.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
...
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
</ItemGroup>
</Project>
To remove a dependency, remove its <PackageReference>
item from the project file.
To add a dependency, run the dotnet add package command, as shown in the following example:
dotnet add package Microsoft.EntityFrameworkCore
To remove a dependency, run the dotnet remove package command, as shown in the following example:
dotnet remove package Microsoft.EntityFrameworkCore
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:
<FrameworkReference Include="Microsoft.AspNetCore.App" />
For more information, see Use the ASP.NET Core shared framework.
.NET atsiliepimas
.NET yra atvirojo kodo projektas. Pasirinkite saitą, kad pateiktumėte atsiliepimą:
Įvykiai
03-17 21 - 03-21 10
Prisijunkite prie meetup serijos, kad sukurtumėte keičiamo dydžio DI sprendimus, pagrįstus realaus pasaulio naudojimo atvejais, su kolegomis kūrėjais ir ekspertais.
Registruotis dabarMokymas
Modulis
Create a new .NET project and work with package dependencies - Training
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.