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

NuGetizer and Central Package Management are not working as expected #544

Open
navruz-rakhimov opened this issue Dec 17, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@navruz-rakhimov
Copy link

navruz-rakhimov commented Dec 17, 2024

Describe the Bug

NuGetizer is ignoring central package management.

Steps to Reproduce

  1. Create an empty solution
  2. Create a Directory.Packages.props and enable central package management for the solution.
<Project>
    <PropertyGroup>
        <EnablePackageVersionOverride>true</EnablePackageVersionOverride>
        <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    </PropertyGroup>
    <ItemGroup>
        <PackageVersion Include="NuGetizer" Version="1.2.3" />
        <PackageVersion Include="Unity" Version="5.11.10" Condition=" '$(TargetFramework)' == 'net8.0' " />
        <PackageVersion Include="Unity" Version="4.0.1" Condition=" '$(TargetFramework)' == 'net472' " />
    </ItemGroup>
</Project>
  1. Add a class library with the following project file content
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFrameworks>net8.0;net472</TargetFrameworks>
        <ImplicitUsings>enable</ImplicitUsings>
        <PackageId>MyClassLib</PackageId>
        <Version>1.0.0</Version>
        <Nullable>enable</Nullable>
        <LangVersion>12</LangVersion>
    </PropertyGroup>
    
    <ItemGroup>
        <PackageReference Include="NuGetizer" />
        <PackageReference Include="Unity" />
    </ItemGroup>
    
</Project>

Expected Behavior

I expected the following dependencies in the nuspec file when I dotnet pack:

<dependencies>
      <group targetFramework="net8.0">
          <dependency id="Unity" version="5.11.10" />
      </group>
      <group targetFramework=".NETFramework4.7.2">
          <dependency id="Unity" version="4.0.1" />
      </group>
</dependencies>

but I am getting:

<dependencies>
      <group targetFramework="net8.0">
          <dependency id="Unity" version="5.11.10" />
      </group>
      <group targetFramework=".NETFramework4.7.2">
          <dependency id="Unity" version="5.11.10" />
      </group>
</dependencies>

Exception with Stack Trace

Version Info

Additional Info

Central Package Management works fine when I use dotnet pack command alone without NuGetizer.
Similarly, I can conditionally specify different versions in the project file with NuGetizer if the Central Package Management disabled.

The problem is that I can't use both Central Package Management and NuGetizer to use different versions of a dependency per target when multitargeting.

Back this issue
Back this issue

@navruz-rakhimov navruz-rakhimov added the bug Something isn't working label Dec 17, 2024
@khamza85
Copy link

See if this one works for you (step 4)

    <PackageReference Include="Unity" Pack="false" />
    <PackageFile PackFolder="Dependency" Include="Unity" Version="4.0.1" Condition=" '$(TargetFramework)' == 'net472' " />
    <PackageFile PackFolder="Dependency" Include="Unity" Version="5.11.10" Condition=" '$(TargetFramework)' == 'net8.0' " />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants