WindowsAppSDK
WindowsAppSDK copied to clipboard
`dotnet publish` results in an error about duplicate files
Describe the bug
Based on this issue: https://github.com/dotnet/maui/issues/9879
Passing a -r win10-x64
to a app .csproj tries to load both a "neutral" and a "RID-specific" dll/pdb into the app:
dotnet publish MyApp.csproj -c Release -f net6.0-windows10.0.19041.0 -r win10-x64
Steps to reproduce the bug
- Clone https://github.com/mattleibow/Maui-Issue-9879
- Execute the publish command:
dotnet publish TestIssue9879/MauiApplication/MauiApplication.csproj -c Release -f net6.0-windows10.0.19041.0 -r win10-x64
- Observe error:
Failure: msbuild.binlog.ziperror APPX1101: Payload contains two or more files with the same destination path 'MauiClassLibrary.pdb'. Source files: error APPX1101: ...\MauiClassLibrary\bin\Release\net6.0-windows10.0.19041.0\MauiClassLibrary.pdb error APPX1101: ...\MauiClassLibrary\bin\Release\net6.0-windows10.0.19041.0\win10-x64\MauiClassLibrary.pdb
- Run build again with custom
RuntimeIdentifierOverride
property set:dotnet publish TestIssue9879/MauiApplication/MauiApplication.csproj -c Release -f net6.0-windows10.0.19041.0 /p:RuntimeIdentifierOverride=win10-x86
- Observe success
Success: msbuild.binlog.zip
Expected behavior
Passing the RID should only apply the the app project, and the class library references should just be non-RID.
Screenshots
No response
NuGet package version
1.1.4
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 21H2 (22000)
IDE
Other
Additional context
I was able to make a workaround:
Add this to the bottom of the app .csproj:
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' and '$(RuntimeIdentifierOverride)' != ''">
<RuntimeIdentifier>$(RuntimeIdentifierOverride)</RuntimeIdentifier>
</PropertyGroup>
Then when executing, use the new property instead of the RID:
dotnet publish MyApp.csproj -c Release -f net6.0-windows10.0.19041.0 /p:RuntimeIdentifierOverride=win10-x86