c#/helper

c# AppendRuntimeIdentifierToOutputPath 옵션

AUSTAR 2024. 4. 23. 23:33

이전에 올렸던 AppendTargetFrameworkToOutputPath 와 비슷한 옵션을 제공한다.

 

2024.04.23 - [c#/helper] - c# AppendTargetFrameworkToOutputPath 옵션

 

c# AppendTargetFrameworkToOutputPath 옵션

c# 비주얼 스튜디오 프로젝트 설정 파일에서 AppendTargetFrameworkToOutputPath 태그 옵션을 이용하면 프로젝트를 빌드하여 출려되는 결과물 경로에 프레임워크 경로를 추가할지 설정할 수 있다. 옵션은

austar.tistory.com

 

C# 프로젝트 설정 파일에서 AppendTargetFrameworkToOutputPath 설정을 통해 프로젝트 빌드 후 출력 경로에 런타임 식별자를 추가할지 설정할 수 있다.

앞서 설명한 AppendTargetFrameworkToOutputPath 옵션과 같이 타겟 런타임 식별자를 보통 지정한 후 프로그램을 만들기때문에 다중 플랫폼을 지정할 예정이 아니라면 해당 옵션을 false 상태로 지정한 후 사용해도 좋다.

 

true, false 옵션을 제공하며 다음과 같이 태그를 설정하여 사용할 수 있다.

<!-- 해당 프로젝트를 컴파일 할 경우, 출력 경로에 해당 런타임 식별자를 추가 할지 설정한다. -->
<!-- AppendRuntimeIdentifierToOutputPath : true		-  bin\Debug\net8.0\win-x64-->
<AppendRuntimeIdentifierToOutputPath>true</AppendRuntimeIdentifierToOutputPath>

true로 설정할 경우, 빌드 후 bin\Debug\net8.0\win-x64 와 같이 win-x64 라는 런타임 식별자가 출력물 경로에 폴더로 추가된다.

 

<!-- 해당 프로젝트를 컴파일 할 경우, 출력 경로에 해당 런타임 식별자를 추가 할지 설정한다. -->
<!-- AppendRuntimeIdentifierToOutputPath : false	-  bin\Debug\net8.0\-->
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>

false 로 설정할 경우, bin\Debug\net8.0 와 같이 win-x64 라는 런타임 식별자가 제거된 후 출력물이 나온다.

 

최종적으로 프로젝트 설정 파일에 넣을 경우 다음과 같은 형태가 된다.

 

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<!-- 빌드시 출력물-->
		<OutputType>WinExe</OutputType>
		<!-- .net 버전 설정-->
		<TargetFramework>net8.0-windows</TargetFramework>
		<!-- null 허용 경고 여부 -->
		<Nullable>enable</Nullable>
		<!--암시적 global using 지시문을 사용 및 사용하지 않도록 설정-->
		<ImplicitUsings>enable</ImplicitUsings>
		<!-- WPF 사용 설정-->
		<UseWPF>true</UseWPF>
		<!-- 해당 프로젝트를 컴파일 할 경우, 출력 경로에 해당 런타임 식별자를 추가 할지 설정한다. -->
		<!-- AppendRuntimeIdentifierToOutputPath : true		-  bin\Debug\net8.0\win-x64-->
		<!-- AppendRuntimeIdentifierToOutputPath : false	-  bin\Debug\net8.0\-->
		<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
	</PropertyGroup>
</Project>

참고 사이트

 

https://learn.microsoft.com/ko-kr/dotnet/core/project-sdk/msbuild-props#appendruntimeidentifiertooutputpath

 

Microsoft.NET.Sdk의 MSBuild 속성 - .NET

.NET SDK에서 이해하는 MSBuild 속성 및 항목에 대한 참조입니다.

learn.microsoft.com