Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

.NET Core 2 이하의 프로젝트에서 System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0.

그동안 멀쩡히 잘 되던 빌드에서 어느 순간 이런 오류가 발생합니다.

1>C:\...[nuget_path]...\system.runtime.compilerservices.unsafe\6.0.0\buildTransitive\netcoreapp2.0\System.Runtime.CompilerServices.Unsafe.targets(4,5): error : System.Runtime.CompilerServices.Unsafe doesn't support netcoreapp2.0. Consider updating your TargetFramework to netcoreapp3.1 or later.
1>Done building project "TestWebApp.csproj" -- FAILED.

실제로 "C:\...[nuget_path]...\system.runtime.compilerservices.unsafe\6.0.0\buildTransitive\netcoreapp2.0\System.Runtime.CompilerServices.Unsafe.targets" 파일에는 다음과 같은 내용을 담고 있어,

<Project InitialTargets="NETStandardCompatError_System_Runtime_CompilerServices_Unsafe_netcoreapp3_1">
  <Target Name="NETStandardCompatError_System_Runtime_CompilerServices_Unsafe_netcoreapp3_1"
          Condition="'$(SuppressTfmSupportBuildWarnings)' == ''">
    <Error Text="System.Runtime.CompilerServices.Unsafe doesn't support $(TargetFramework). Consider updating your TargetFramework to netcoreapp3.1 or later." />
  </Target>
</Project>

오류가 발생하는 것이 맞습니다. 문제는, 프로젝트에 아무런 변경도 없었는데, 단순히 NuGet Local Cache에 있던 "System.Runtime.CompilerServices.Unsafe" 패키지가 업데이트된 것만으로 저런 오류가 발생하고 있다는 점입니다.

이 문제를 해결하려면 당연히 프로젝트를 .NET Core App 3.1 이상으로 올리면 되지만, 못 올리는 이유가 있다면 아래의 이슈에 따라,

System.Runtime.CompilerServices.Unsafe is not obey .NET Standard 2.0 (it should support .NET Core 2.1 App) #77367
; https://github.com/dotnet/runtime/issues/77367

csproj에 다음의 항목을 추가해 주면 됩니다.

<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> 




우회 방법은 찾았지만, 근본적으로 왜 저 targets 파일이 포함될 수 있는지 잘 이해가 안 됩니다. 해당 경로의 System.Runtime.CompilerServices.Unsafe 패키지 버전은 6.0.0인데, ASP.NET Core 2.0에서 참조 경로에 걸려 있는 버전은 4.4.0입니다. 그리고, 그 버전의 NuGet Cache에는 buildTransitive 디렉터리 자체가 없습니다.

따라서, 원래의 경우대로라면, 즉 이전에 컴파일이 잘 되던 경우처럼 4.4.0 버전의 참조로 오류가 발생하지 않아야 하는데, 저렇게 급작스럽게 오류가 나야 할 이유를 모르겠군요. ^^




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 1/3/2024]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
13392정성태7/16/20233617오류 유형: 872. Oracle - ORA-01031: insufficient privileges
13391정성태7/14/20233633닷넷: 2132. C# - sealed 클래스의 메서드를 callback 호출했을 때 인라인 처리가 될까요?
13390정성태7/12/20233546스크립트: 53. 파이썬 - localhost 호출 시의 hang 현상
13389정성태7/5/20233615개발 환경 구성: 684. IIS Express로 호스팅하는 웹을 WSL 환경에서 접근하는 방법
13388정성태7/3/20233804오류 유형: 871. 윈도우 탐색기에서 열리지 않는 zip 파일 - The Compressed (zipped) Folder '[...].zip' is invalid. [1]파일 다운로드1
13387정성태6/28/20233869오류 유형: 870. _mysql - Commands out of sync; you can't run this command now
13386정성태6/27/20233989Linux: 61. docker - 원격 제어를 위한 TCP 바인딩 추가
13385정성태6/27/20234189Linux: 60. Linux - 외부에서의 접속을 허용하기 위한 TCP 포트 여는 방법
13384정성태6/26/20233902.NET Framework: 2131. C# - Source Generator로 해결하는 enum 박싱 문제파일 다운로드1
13383정성태6/26/20233634개발 환경 구성: 683. GPU 런타임을 사용하는 Colab 노트북 설정
13382정성태6/25/20233682.NET Framework: 2130. C# - Win32 API를 이용한 윈도우 계정 정보 (예: 마지막 로그온 시간)파일 다운로드1
13381정성태6/25/20234098오류 유형: 869. Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
13380정성태6/24/20233502스크립트: 52. 파이썬 3.x에서의 동적 함수 추가
13379정성태6/23/20233538스크립트: 51. 파이썬 2.x에서의 동적 함수 추가
13378정성태6/22/20233422오류 유형: 868. docker - build 시 "CANCELED ..." 뜨는 문제
13377정성태6/22/20237299오류 유형: 867. 파이썬 mysqlclient 2.2.x 설치 시 "Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually" 오류
13376정성태6/21/20233685.NET Framework: 2129. C# - Polly를 이용한 클라이언트 측의 요청 재시도파일 다운로드1
13375정성태6/20/20233361스크립트: 50. Transformers (신경망 언어모델 라이브러리) 강좌 - 2장 코드 실행 결과
13374정성태6/20/20233455오류 유형: 866. 파이썬 - <class 'AttributeError'> module 'flask.json' has no attribute 'JSONEncoder'
13373정성태6/19/20234744오류 유형: 865. 파이썬 - pymssql 설치 관련 오류 정리
13372정성태6/15/20233317개발 환경 구성: 682. SQL Server TLS 통신을 위해 사용되는 키 길이 확인 방법
13371정성태6/15/20233413개발 환경 구성: 681. openssl - 인증서 버전(V1 / V3)
13370정성태6/14/20233563개발 환경 구성: 680. C# - Ubuntu + Microsoft.Data.SqlClient + SQL Server 2008 R2 연결 방법 - TLS 1.2 지원
13369정성태6/13/20233371개발 환경 구성: 679. PyCharm(을 비롯해 JetBrains에 속한 여타) IDE에서 내부 Window들의 탭이 없어진 경우
13368정성태6/13/20233532개발 환경 구성: 678. openssl로 생성한 인증서를 SQL Server의 암호화 인증서로 설정하는 방법
13367정성태6/10/20233690오류 유형: 864. openssl로 만든 pfx 인증서를 Windows Server 2016 이하에서 등록 시 "The password you entered is incorrect" 오류 발생
1  2  3  4  5  6  7  8  9  [10]  11  12  13  14  15  ...