C#/WPF

[WPF] Multi TargetFramework

딸기우유중독 2024. 12. 6. 11:49

 

 

여러 플랫폼에 지원하는 라이브러리, 응용프로그램을 만들 때

ex) DevExpress 컴포넌트 사용하는데 net7.0 까지 지원하고 net8.0, 9.0 등은 지원하지 않는데

net9 용으로 만들어진 라이브러리를 가져다쓰려고하면 프레임워크 안맞는다고 에러나는 경우

 

라이브러리를 멀티 프레임워크 지원으로해서 net6.0~ net9.0까지 지원하도록 빌드해서 가져다 쓰면 해결.

 

net6.0 ~ net9.0 등까지 지원하는 라이브러리를 사용하고 싶을 때

 

 

//		<TargetFramework>net6.0-windows</TargetFramework>

//TargetFramework에 s 붙여야 함.
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>

 

 

 

 

프레임워크 별로 dll or exe 만들어짐.

 

 

 

 

멀티 And 프레임워크 조건부 설정.

 

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup Condition="'$(TargetFramework)' == 'net452'">
    <PackageReference Include="Microsoft.Azure.DocumentDB">
      <Version>1.12.0</Version>
    </PackageReference>
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'">
    <PackageReference Include="Microsoft.Azure.DocumentDB.Core">
    <Version>1.1.0</Version>
    </PackageReference>
  </ItemGroup>
</Project>

 

https://stackoverflow.com/questions/42747977/how-do-you-multi-target-a-net-core-class-library-with-csproj

 

How do you multi-target a .NET Core class library with csproj?

When .NET Core still used the project.json format, you could build a class library targeting multiple frameworks (e.g. net451, netcoreapp1.0). Now that the official project format is csproj using

stackoverflow.com

 

https://learn.microsoft.com/ko-kr/nuget/create-packages/multiple-target-frameworks-project-file

 

프로젝트 파일에서 NuGet 패키지의 멀티 타기팅

프로젝트 파일의 단일 NuGet 패키지 내에서 여러 .NET Framework 버전을 대상으로 하는 다양한 방법에 대한 설명입니다.

learn.microsoft.com

 

 

728x90