Open Closed

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


User avatar
0
alper created
Support Team Director

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

C:\Program Files\dotnet\sdk\6.0.100-rc.1.21458.32\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: 

D:\Github\volo\abp\lepton-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton\compilerconfig.json,
D:\Github\volo\abp\bookstore\src\Acme.BookStore.Theme\compilerconfig.json, 

D:\Github\volo\abp\lepton-theme\src\Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton\package.json, 
D:\Github\volo\abp\bookstore\src\Acme.BookStore.Web\package.json. 

D:\Github\volo\abp\bookstore\src\Acme.BookStore.Web\Acme.BookStore.Web.csproj

1 Answer(s)
  • User Avatar
    1
    alper created
    Support Team Director

    Issue:

    The issue raises after .NET 6 migration. There's a new feature that blocks multiple files to be copied to the same target directory with the same file name. See https://docs.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 the previous .NET5.

    <ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles>
    

    Solution #2:

    Exlude the problemmatic 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>
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38