umbraco-contentment icon indicating copy to clipboard operation
umbraco-contentment copied to clipboard

.NET Publish with .NET 6+ errors with "Found multiple publish output files with the same relative path

Open RachBreeze opened this issue 1 year ago • 1 comments

Which Contentment version are you using?

4.4.6

Which Umbraco version are you using? For example: 8.14.1 - don't just write v8

10.7.0

Bug summary

When performing a .NET Publish .NET 6 (or newer) the publish will error with:

C:\Program Files\dotnet\sdk\7.0.401\Sdks\[Microsoft.NET](http://microsoft.net/).Sdk\targets\[Microsoft.NET](http://microsoft.net/).ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: D:\a\1\s\[CLIENTNAME]\App_Plugins\Contentment\backoffice\contentment\index.html

Please note the files are not included in the *.csproj

The issue occurs because of a change introduced in .NET 6 to prevent duplicate files in the publish output, which can cause build breaks or unpredictable behaviour. For more information on the change see Generate error for duplicate files in publish output.

The work around which must be tested, as it prevents the check triggering for duplicate files, including those outside of Contentment is to edit the *.csproj which references Contentment, and add:

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

Steps to reproduce

The issue was found when executing the following yml in Azure DevOps:

    #Restore and build
    -   task: DotNetCoreCLI@2
        displayName: 'dotnet publish'
        inputs:
            command: publish
            arguments: '-o $(build.artifactstagingdirectory) -c Release --nologo
    /p:WebPublishMethod=Package 
    /p:PackageAsSingleFile=true 
    /p:DeleteExistingFiles=True'

Expected result / actual result

I was not expecting the build error

Do you have Umbraco ModelsBuilder enabled?

  • [X] Yes, it is enabled.

What browsers are you seeing the problem on?

No response

RachBreeze avatar Oct 22 '23 11:10 RachBreeze

To note, I haven't been able to reproduce this issue on my local machine, the dotnet publish command appears to overwrite the target files as expected.

I'm glad that the <ErrorOnDuplicatePublishOutputFiles> workaround will mitigate the issue for anyone experiencing this.

In the meantime, if anyone in the wider community knows of a way that Contentment itself can workaround this scenario, please do let me know.

That said, in upcoming Contentment v5, the Razor Class Library approach will be implemented, so that may negate this issue completely. (Please correct me if I'm mistaken).

leekelleher avatar Oct 30 '23 15:10 leekelleher

Now that Contentment v5.0.0 has been released, and supports the Razor Class Library approach for the web assets, I believe the duplicate output files should no longer be an issue. I'll close off this ticket.

leekelleher avatar May 18 '24 10:05 leekelleher