Code/C#

C# 단일 파일 빌드: 파일 중복 오류

Segel 2021. 7. 25. 02:39

문제:

조건:
Target framework: net5.0-windows
Deployment mode: Self-contained
Taget runtime: win-x64
File publish options: Produce single file, Enable ReadyToRun compilation

    위 조건에서 Publish 시 오류 발생
    하지만 몇 가지 실험을 해 본 결과 위 조건들 중 Produce single file만 활성화되어있어도 발생하는 것 같음

 

    4>The "GenerateBundle" task failed unexpectedly.
    4>System.ArgumentException: Invalid input specification: Found multiple entries with the same BundleRelativePath

    4>   at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)
    4>   at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore()
    4>   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
    4>   at Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
    4>   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
    4>   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

    위와 같은 오류와 함께 Publish가 중단됨

 

원인:

    본 프로젝트와 ProjectReference로 지정된 프로젝트 간에 중복되는 파일이 있고 각 파일들의 Build Action 또한 같음

 

해결:

    1. 두 프로젝트 간에 중복되는 파일을 제거
    2. 반드시 두 프로젝트에 각각 필요하다면 Build Action을 다르게 지정

반응형