Skip to content
New issue

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

Add support for Central Package Management #46

Closed
stevenvolckaert opened this issue Dec 2, 2022 · 2 comments
Closed

Add support for Central Package Management #46

stevenvolckaert opened this issue Dec 2, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@stevenvolckaert
Copy link

stevenvolckaert commented Dec 2, 2022

The release of NuGet 6.2.0, released with Visual Studio 2022 17.2, makes it possible to manage the versions of package references centrally in a single (or multiple, if one would wish) Directory.Packages.props file.

See Central Package Management (CPM) on Microsoft Docs.

I've been migrating some of our projects to use CPM. Today I tried to migrate our first Sdk="MSBuild.SDK.SystemWeb/4.0.82" project, but I'm getting a NU1008 error:

Projects that use central package version management should not define the version on the PackageReference items but on the PackageVersion items: Microsoft.CodeDom.Providers.DotNetCompilerPlatform;Microsoft.Net.Compilers.Toolset.

I presume MSBuild.SDK.SystemWeb would need to be updated to support this scenario?

Basically, when a Directory.Packages.props file is defined / used, the Version attribute on packages Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers.Toolset should either be removed or be updated to VersionOverride.

Could this be considered for a future, perhaps for the next release?

For the meantime, I could quite easily workaround this issue by setting property ExcludeASPNetCompilers to true:

<PropertyGroup>
  <ExcludeASPNetCompilers>true</ExcludeASPNetCompilers>
</PropertyGroup>

So supporting CPM is by no means an urgent feature request.

Thank you!

@CZEMacLeod
Copy link
Owner

The SDK already supports the Microsoft.Build.CentralPackageVersions SDK/package mechanism for doing this. It detects and omits the version numbers for package references based on the property UsingMicrosoftCentralPackageVersionsSdk.
If you add this (set to true) it should work as expected for the NuGet intrinsic system too.
The SDK could be updated to check for the ManagePackageVersionsCentrally property too, and I will look at doing that in a future update.

<Project>
  <PropertyGroup>
    <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    <UsingMicrosoftCentralPackageVersionsSdk>true</UsingMicrosoftCentralPackageVersionsSdk>
  </PropertyGroup>
  <ItemGroup>
    <PackageVersion Include="Microsoft.Net.Compilers.Toolset" Version="4.3.0" />
    <PackageVersion Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="3.6.0" />
  </ItemGroup>
</Project>

@CZEMacLeod CZEMacLeod added enhancement New feature or request good first issue Good for newcomers labels Dec 2, 2022
@stevenvolckaert
Copy link
Author

I confirm this works, thank you for your support @CZEMacLeod!

brandon-hurler added a commit to brandon-hurler/MSBuild.SDK.SystemWeb that referenced this issue Feb 8, 2023
…ng RazorLibrary to support predefined PackageVersions.
brandon-hurler added a commit to brandon-hurler/MSBuild.SDK.SystemWeb that referenced this issue Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants