1.添加 PackageReference
在项目文件中使用以下语法添加依赖项:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.7" />
</ItemGroup>
2.版本范围
引用包依赖项时,NuGet 支持使用间隔表示法来指定版本范围,汇总如下:
版本 | 应用的规则 | 说明 |
---|---|---|
1.0 | x ≥ 1.0 | 最低版本(包含) |
(1.0,) | x > 1.0 | 最低版本(独占) |
[1.0] | x == 1.0 | 精确的版本匹配 |
(,1.0] | x ≤ 1.0 | 最高版本(包含) |
(,1.0) | x < 1.0 | 最高版本(独占) |
[1.0,2.0] | 1.0 ≤ x ≤ 2.0 | 精确范围(包含) |
(1.0,2.0) | 1.0 < x < 2.0 | 精确范围(独占) |
[1.0,2.0) | 1.0 ≤ x < 2.0 | 混合了最低版本(包含)和最高版本(独占) |
(1.0) | 无效 | 无效 |
原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/csharp/csharpenv/7836.html