Skip to content

MAUI is not compatible with ManagePackageVersionsCentrally #27840

Closed

Description

@aelij

Describe the bug

When using NuGet Central Package Management and MAUI installed, we get the following error:

error NU1507: There are 2 package sources defined in your configuration. When using central package management, please map your package sources with package source mapping (https://aka.ms/nuget-package-source-mapping) or specify a single package source. The following sources are defined: https://pkgs.dev.azure.com/..., C:\Program Files\dotnet\library-packs

To Reproduce

  1. Install MAUI
  2. Enable CPS by adding a Directory.Packages.props file with <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
  3. dotnet restore

Workaround

<DisableImplicitLibraryPacksFolder>true</DisableImplicitLibraryPacksFolder>

Further technical details

.NET SDK (reflecting any global.json):
 Version:   6.0.400
 Commit:    7771abd614

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.400\

global.json file:
  C:\src\azdo\ADP\global.json

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  3.1.422 [C:\Program Files\dotnet\sdk]
  5.0.408 [C:\Program Files\dotnet\sdk]
  6.0.101 [C:\Program Files\dotnet\sdk]
  6.0.108 [C:\Program Files\dotnet\sdk]
  6.0.303 [C:\Program Files\dotnet\sdk]
  6.0.400 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.28 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Activity

  1. ghost added
    untriagedRequest triage from a team member
    on Sep 13, 2022
  2. KalleOlaviNiemitalo commented on Oct 19, 2022

    @KalleOlaviNiemitalo
    Contributor

    May be a duplicate of NuGet/Home#11951.

  3. nickrandolph commented on Oct 25, 2022

    @nickrandolph

    @jeffkl any thoughts on this? If related to NuGet/Home#11951, when are we likely to see this fix being widely available?

  4. jeffkl commented on Oct 25, 2022

    @jeffkl
    Contributor

    @nickrandolph the change shipped with Visual Studio 2022 17.4 and .NET SDK 6.0.4xx

  5. KalleOlaviNiemitalo commented on Oct 25, 2022

    @KalleOlaviNiemitalo
    Contributor

    This issue is still reproducible with .NET SDK 6.0.402, which includes NuGet 6.3.1-rc.1+01bc4df1ef99c9c213f892ec8b25e46b23c7cfb1.01bc4df1ef99c9c213f892ec8b25e46b23c7cfb1 (see NuGet/Home#11974 for the strange versioning). https://github.com/NuGet/NuGet.Client/blob/01bc4df1ef99c9c213f892ec8b25e46b23c7cfb1/src/NuGet.Core/NuGet.Commands/RestoreCommand/RestoreCommand.cs#L466 does not include the changes that were made in NuGet/NuGet.Client#4764. @jeffkl, did you mean some other change?

  6. jeffkl commented on Oct 25, 2022

    @jeffkl
    Contributor

    @KalleOlaviNiemitalo okay sorry at some point NuGet stopped inserting into .NET 6. So I'd imagine the change is only in .NET 7 RC1 and above.

  7. ganeshkhatri commented on Nov 26, 2023

    @ganeshkhatri

    The issue is again raised in dotnet 8.0. Works fine with dotnet 7.0.

  8. Sen-Gupta commented on Feb 4, 2024

    @Sen-Gupta

    Issue occurs in .Net 8!

  9. Sen-Gupta commented on Feb 4, 2024

    @Sen-Gupta

    Workaround:

    Add following to your MAUI Project file, until the issue is fixed.

    <PropertyGroup>
      <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
    </PropertyGroup>
  10. james-world commented on Feb 14, 2024

    @james-world

    Workaround:

    Add following to your MAUI Project file, until the issue is fixed.

    <PropertyGroup>
      <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
    </PropertyGroup>
    

    It's not enough to do this if you actually want CPM in your projects; you need the undocumented DisableImplicitLibraryPacksFolder property added to your Directory.Packages.props (or other project file). This is mentioned in #28642.

    Personally, I've never used MAUI - think I may have inadvertently installed it on my Mac as part of Visual Studio for Mac (now uninstalled since it's been discontinued) but it's left detritus on my machine I'm not sure how to clean properly. This fixed it for me:

    <PropertyGroup>
      <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
      <DisableImplicitLibraryPacksFolder>true</DisableImplicitLibraryPacksFolder>
    </PropertyGroup>
  11. epsmae commented on Mar 8, 2024

    @epsmae

    The workaround mentioned by @james-world works for me, below you see the snippets.
    I can use central package management like that in the referenced non maui and the test projects.
    Not what I desired but hopefully this gets soon fixed.

    Directory.Packages.props

    <Project>
      <PropertyGroup>
        <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
    
        <!-- See Maui Issue: https://github.com/dotnet/sdk/issues/27840 -->
        <DisableImplicitLibraryPacksFolder>true</DisableImplicitLibraryPacksFolder>
      </PropertyGroup>
    
      
      
      <!-- Microsoft Package Versions -->
      <ItemGroup>
        <PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
        ...
      </ItemGroup>
      
      ...
    </Project>
    
    

    Maui Project

    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>
        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
        <TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('android')) And !$([MSBuild]::IsOSPlatform('ios'))">$(TargetFrameworks);net8.0</TargetFrameworks>
    
        <!-- See Maui Issue: https://github.com/dotnet/sdk/issues/27840 -->
        <ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
      </ItemGroup>
    
    
      <ItemGroup>
        <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.6" />
      </ItemGroup>
      
      ...
    
    </Project>
    
  12. epsmae commented on Dec 19, 2024

    @epsmae

    Are there any news regarding that in .Net 9?
    Is it planned that maui will support Directory.Packages.props in the future?

  13. fabEps commented on Apr 4, 2025

    @fabEps
  14. aelij commented on Oct 30, 2025

    @aelij
    ContributorAuthor

    @fabEps Sounds like it. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions