Essentially what the subject says. Create a sample MAUI app in Windows and reference 2 custom nugets of yours that contain a README.md file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0-windows10.0.19041.0;</TargetFrameworks>
<UseMaui>true</UseMaui>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<SingleProject>true</SingleProject>
<RootNamespace>MauiApp1</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>MauiApp1</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.mauiapp1</ApplicationId>
<ApplicationIdGuid>141756bd-c085-42ee-a5b6-4e86c124cfwe3</ApplicationIdGuid>
<!-- Versions -->
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4"/>
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/>
<!-- Images -->
<MauiImage Include="Resources\Images\*"/>
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185"/>
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*"/>
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>
<ItemGroup>
<!-- these 2 nugets come with their respective README.md files -->
<PackageReference Include="Foo.Bar" Version="1.2.3" />
<PackageReference Include="Ping.Pong" Version="4.5.6" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0"/>
</ItemGroup>
</Project>
Upon building I get the following error every time:
-r:"C:\Users\Dominic\.nuget\packages\microsoft.windows.sdk.net.ref\10.0.19041.31\lib\net6.0\Microsoft.Windows.SDK.NET.dll"
-r:"C:\Users\Dominic\.nuget\packages\microsoft.windows.sdk.net.ref\10.0.19041.31\lib\net6.0\WinRT.Runtime.dll"
--out:"obj\Release\net8.0-windows10.0.19041.0\win10-x64\R2R\WinRT.Runtime.dll"
C:\Users\Dominic\.nuget\packages\microsoft.windows.sdk.net.ref\10.0.19041.31\lib\net6.0\WinRT.Runtime.dll
0>Microsoft.Build.Msix.Packaging.targets(1500,5): Error APPX1101 : Payload contains two or more files with the same destination path 'README.md'. Source files:
C:\...\foo.bar\1.2.3\contentFiles\any\netstandard2.1\README.md
C:\...\ping.pong\4.5.6\contentFiles\any\netstandard2.1\README.md
0>------- Finished building project: MauiApp1. Succeeded: False. Errors: 1. Warnings: 0
Build completed in 00:00:39.266
This error occurs only when targeting windows (if we target android or ios or maccatalyst then it doesn't occur). Same error both when using net7 and net8 sdks (tested with 8.0.101). What gives?
Well as it turned out both of my custom nugets 'foo.bar' and 'ping.pong' had README.md included as content in their respective .csproj files like so:
<ItemGroup>
<Content Include="..\README.md">
<Link>README.md</Link>
</Content>
</ItemGroup>
This is what was causing the error when building for windows. I removed the above section from both .csproj files + regenerated their respective nugets and once I upgraded the MAUI project to use those new nugets the problem went away. Hopefully this will help some folks out there save a few hours worth of time.
PS: The original error is a bit cryptic though - took some time to connect the dots properly to reach the proper interpretation. I originally thought that the problem was that the README.md file was getting included at the root folder of the nuget folder-structure inside the package which wasn't the case.