We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https://medium.com/@MilanJovanovicTech/central-package-management-in-net-simplify-nuget-dependencies-1f6c744f79d7
The text was updated successfully, but these errors were encountered:
如果你的项目解决方案中包含了很多 C# 工程项目,但是由于管理或者其他原因,同一个依赖包包含了不同的版本。这样会增加管理的复杂程度,比如当要升级版本的时候,需要更改所有的出现的地方。而且如果项目之间存在引用关系,会导致版本冲突的问题。所以 .NET 提供了一个集中包管理机制。首先在项目目录下创建一个 Directory.Packages.props 文件
.NET
Directory.Packages.props
<Project> <PropertyGroup> <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> </PropertyGroup> <ItemGroup> <PackageVersion Include="Newtonsoft.Json" Version="13.0.3" /> <PackageVersion Include="Serilog" Version="4.1.0" /> <PackageVersion Include="Polly" Version="8.5.0" /> </ItemGroup> </Project>
这样在项目中的 csproj 文件,就不需要制定版本
csproj
<ItemGroup> <PackageReference Include="Newtonsoft.Json" /> <PackageReference Include="AutoMapper" /> <PackageReference Include="Polly" /> </ItemGroup>
如果在项目中覆盖掉版本,可以 VersionOverride 属性
VersionOverride
<PackageReference Include="Serilog" VersionOverride="3.1.1" />
当然也可以制定某个包让每个工程项目使用
<ItemGroup> <GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="10.3.0.106239" /> </ItemGroup>
Sorry, something went wrong.
No branches or pull requests
https://medium.com/@MilanJovanovicTech/central-package-management-in-net-simplify-nuget-dependencies-1f6c744f79d7
The text was updated successfully, but these errors were encountered: