Skip to content

Commit

Permalink
[build] Enable NuGet's Central Package Management (#1114)
Browse files Browse the repository at this point in the history
Context: c936d09

Enable NuGet's [Central Package Management][0].  Although this is
similar to the "homegrown" centralized package version management
we currently have (c936d09), using the "official" version means that
there is additional tooling support available, such as being
supported by `dotnet add package`, Visual Studio, and dependabot.

Central Package Management also requires [Package Source Mapping][1],
so we also add that information to our `NuGet.config`.

[0]: https://learn.microsoft.com/nuget/consume-packages/central-package-management
[1]: https://learn.microsoft.com/nuget/consume-packages/package-source-mapping
  • Loading branch information
jpobst committed May 26, 2023
1 parent 93c50fe commit 8c9eece
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ProduceReferenceAssemblyInOutDir>true</ProduceReferenceAssemblyInOutDir>
<DotNetTargetFrameworkVersion>7.0</DotNetTargetFrameworkVersion>
<DotNetTargetFramework>net$(DotNetTargetFrameworkVersion)</DotNetTargetFramework>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>

<Import
Expand Down
25 changes: 3 additions & 22 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,18 @@

<!-- Add Roslyn analyzers NuGet to all projects -->
<ItemGroup Condition=" '$(DisableRoslynAnalyzers)' != 'True' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<!-- NuGet Dependencies -->
<!-- Set Assets for NUnit3TestAdapter -->
<ItemGroup>
<PackageReference Update="GitInfo" Version="2.1.2" />
<PackageReference Update="HtmlAgilityPack" Version="1.11.30" />
<PackageReference Update="Irony" Version="1.1.0" />
<PackageReference Update="Microsoft.Build.Framework" Version="17.3.2" />
<PackageReference Update="Microsoft.Build.Utilities.Core" Version="17.3.2" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
<PackageReference Update="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Update="Microsoft.DotNet.GenAPI" Version="7.0.0-beta.22103.1" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageReference Update="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageReference Update="Microsoft.Xml.SgmlReader" Version="1.8.16" />
<PackageReference Update="Mono.CSharp" Version="4.0.0.143" />
<PackageReference Update="Mono.Linq.Expressions" Version="2.0.0" />
<PackageReference Update="Mono.Options" Version="6.12.0.148" />
<PackageReference Update="Mono.Terminal" Version="5.4.2" />
<PackageReference Update="nunit" Version="3.13.2" />
<PackageReference Update="NUnit.ConsoleRunner" Version="3.12.0" />
<PackageReference Update="NUnit3TestAdapter" Version="4.0.0">
<PackageReference Update="NUnit3TestAdapter">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Update="protobuf-net" Version="2.4.4" />
</ItemGroup>

<Import Project="build-tools\scripts\VersionInfo.targets" />
Expand Down
31 changes: 31 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project>

<PropertyGroup>
<_XamarinAndroidCecilVersion Condition=" '$(_XamarinAndroidCecilVersion)' == '' ">0.11.4</_XamarinAndroidCecilVersion>
</PropertyGroup>

<ItemGroup>
<PackageVersion Include="GitInfo" Version="2.1.2" />
<PackageVersion Include="HtmlAgilityPack" Version="1.11.30" />
<PackageVersion Include="Irony" Version="1.1.0" />
<PackageVersion Include="Microsoft.Build.Framework" Version="17.3.2" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.3.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.DotNet.GenAPI" Version="7.0.0-beta.22103.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0-preview-20221003-04" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="Microsoft.Xml.SgmlReader" Version="1.8.16" />
<PackageVersion Include="Mono.Cecil" Version="$(_XamarinAndroidCecilVersion)" />
<PackageVersion Include="Mono.CSharp" Version="4.0.0.143" />
<PackageVersion Include="Mono.Linq.Expressions" Version="2.0.0" />
<PackageVersion Include="Mono.Options" Version="6.12.0.148" />
<PackageVersion Include="Mono.Terminal" Version="5.4.2" />
<PackageVersion Include="nunit" Version="3.13.2" />
<PackageVersion Include="NUnit.ConsoleRunner" Version="3.12.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageVersion Include="protobuf-net" Version="2.4.4" />
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,14 @@
<!-- For Microsoft.DotNet.GenAPI -->
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" protocolVersion="3" />
</packageSources>

<packageSourceMapping>
<!-- key value for <packageSource> should match key values from <packageSources> element -->
<packageSource key="dotnet-public">
<package pattern="*" />
</packageSource>
<packageSource key="dotnet-eng">
<package pattern="Microsoft.DotNet.GenAPI" />
</packageSource>
</packageSourceMapping>
</configuration>
5 changes: 1 addition & 4 deletions build-tools/scripts/cecil.projitems
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_XamarinAndroidCecilVersion Condition=" '$(_XamarinAndroidCecilVersion)' == '' ">0.11.4</_XamarinAndroidCecilVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(_XamarinAndroidCecilPath)' == '' ">
<PackageReference Include="Mono.Cecil" Version="$(_XamarinAndroidCecilVersion)" />
<PackageReference Include="Mono.Cecil" />
</ItemGroup>
<ItemGroup Condition=" '$(_XamarinAndroidCecilPath)' != '' ">
<Reference Include="$(_XamarinAndroidCecilPath)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Import Project="..\..\build-tools\scripts\cecil.projitems" />
-->
<ItemGroup>
<PackageReference Include="Mono.Cecil" Version="0.11.4" />
<PackageReference Include="Mono.Cecil" />
<PackageReference Include="Mono.Linq.Expressions" />
</ItemGroup>

Expand Down

0 comments on commit 8c9eece

Please sign in to comment.