Publish error: Found multiple publish output files with the same relative path

Total
0
Shares

When I publish my ABP project I get the following error:

C:Program Filesdotnetsdk6.0.100-rc.1.21458.32SdksMicrosoft.NET.SdktargetsMicrosoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: 

D:Githubvoloabplepton-themesrcVolo.Abp.AspNetCore.Mvc.UI.Theme.Leptoncompilerconfig.json,
D:GithubvoloabpbookstoresrcAcme.BookStore.Themecompilerconfig.json, 

D:Githubvoloabplepton-themesrcVolo.Abp.AspNetCore.Mvc.UI.Theme.Leptonpackage.json, 
D:GithubvoloabpbookstoresrcAcme.BookStore.Webpackage.json. 

D:GithubvoloabpbookstoresrcAcme.BookStore.WebAcme.BookStore.Web.csproj

Solution

Issue:

The issue raises after .NET 6 migration.
There’s a new feature that blocks multiple files from being copied to the same target directory with the same file name.
See https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/6.0/duplicate-files-in-output

Solution #1 (workaround):

You can add the following build property to all your publishable (*.Web) projects’ *.csproj files.
This property will bypass this check and works as previously, in .NET5.

<PropertyGroup><ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles></PropertyGroup>

Solution #2:

Exclude the problematic files to be copied to the output folder.
In this example we’ll exclude these files: compilerconfig.json and package.json.

Add the following lines to your common.props (located in the root directory of your solution):

<Content Remove="compilerconfig.json;package.json"/>
<None Include="compilerconfig.json;package.json">
  <ExcludeFromSingleFile>true</ExcludeFromSingleFile>
  <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>

Source: StackOverflow.com

Leave a Reply

Your email address will not be published. Required fields are marked *