WPF 프로젝트 빌드시 어셈블리 속성 중복 에러 해결 방법
😢상황
- 하나의 솔루션에 WPF 프로젝트와 WPF 라이브러리 프로젝트를 생성함
- 솔루션 빌드 시 다음의 에러가 발생함
에러 메시지
CS0579 'global::System.Runtime.Versioning.TargetFrameworkAttribute' 특성이 중복되었습니다.
CS0579 'System.Reflection.AssemblyCompanyAttribute' 특성이 중복되었습니다.
CS0579 'System.Reflection.AssemblyConfigurationAttribute' 특성이 중복되었습니다.
CS0579 'System.Reflection.AssemblyFileVersionAttribute' 특성이 중복되었습니다.
CS0579 'System.Reflection.AssemblyInformationalVersionAttribute' 특성이 중복되었습니다.
CS0579 'System.Reflection.AssemblyProductAttribute' 특성이 중복되었습니다.
CS0579 'System.Reflection.AssemblyTitleAttribute' 특성이 중복되었습니다.
CS0579 'System.Reflection.AssemblyVersionAttribute' 특성이 중복되었습니다.
CS0579 'System.Runtime.Versioning.TargetPlatformAttribute' 특성이 중복되었습니다.
🛠️해결법
프로젝트 .csproj 파일 PropertyGroup 속성 아래 다음 속성 추가하기
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
✅정리: 왜 이게 효과 있었는가?
- WPF 라이브러리 프로젝트는 자동으로 TargetFrameworkAttribute를 생성하려고 했고
- 동시에 WPF 애플리케이션 프로젝트도 해당 속성을 생성
- 그 결과, 컴파일할 때 같은 어셈블리 속성이 중복되어 오류 발생
👉 GenerateTargetFrameworkAttribute=false를 설정하면서, 라이브러리 쪽에서 이 속성 생성을 막아서 중복이 해결함