Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
(연관된 글이 1개 있습니다.)

AssemblyName을 .csproj에서 바꾼 경우 빌드 오류 발생하는 문제

예를 들어, 64비트로 빌드한 경우 EXE 이름을 바꾸기 위해 다음과 같이 .csproj에서 AssemblyName을 편집할 수 있습니다.

<PropertyGroup>
    <X64Postfix>64</X64Postfix>
</PropertyGroup>

<PropertyGroup Condition="'$(Platform)' == 'x64'">
    <AssemblyName>x86x64test$(X64Postfix)</AssemblyName>
</PropertyGroup>

그럼, x64 빌드인 경우 x86x64test64.exe로 출력이 되지만 그 외에는 x86x64test.exe로 출력이 됩니다. 따라서 x64 빌드로 출력 창을 보면,
1>------ Build started: Project: x86x64test, Configuration: Debug x64 ------
1>  x86x64test -> F:\x86x64test\bin\x64\Debug\x86x64test64.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

위와 같이 x86x64test64.exe로 나옵니다. 그런데, 비주얼 스튜디오에서는 .csproj의 이런 변화를 감지하지 못합니다. 그래서 x64 빌드로 맞춰놓고 F5(또는 Ctrl + F5)로 실행하면 다음과 같은 오류가 발생합니다.

Visual Studio cannot start debugging because the debug target 'F:\x86x64test\bin\x64\Debug\x86x64test.exe' is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly.


x86x64test64.exe로 빌드되었지만 비주얼 스튜디오는 여전히 x86x64test.exe로 실행하려고 하기 때문입니다.




이런 경우, 사실 우리가 비주얼 스튜디오 개발자가 아닌 한 별다르게 할 수 있는 것이 없습니다. 즉, 우회 해결을 해야 한다는 건데요, 제가 생각한 방법은 mklink를 이용해 x86x64test64.exe에 대한 Hard Link로 x86x64test.exe 파일을 생성해 주는 것입니다. 이를 위해 "Build Events" / "Post-build event command line"에 다음과 같은 코드를 넣어주면 됩니다.

if EXIST "$(TargetDir)x86x64test.exe" goto END_BUILD

mklink /H "$(TargetDir)x86x64test.exe" "$(TargetPath)"

:END_BUILD

이렇게 해주면 Hard link로 x86x64test.exe 링크 파일이 생성되고 이는 x86x64test64.exe를 가리키기 때문에 비주얼 스튜디오의 실행에도 영향이 없습니다.

또 다르게 생각할 수 있는 방법은, 어차피 대부분의 경우 개발자는 디버그 빌드에서 개발할 것이고 릴리스 빌드는 빌드 스크립트를 통해 배포본을 만들 테니 아예 AssemblyName 변경을 릴리스 빌드에 대해서만 해주는 것입니다.

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <AssemblyName>x86x64test$(X64Postfix)</AssemblyName>
</PropertyGroup>

(첨부 파일은 mklink로 이벤트를 걸은 예제 프로젝트를 싣고 있습니다.)

마지막으로 다음의 글도 참고하시면 좋습니다. ^^

MSBuild를 이용한 닷넷 응용프로그램의 플랫폼(x86/x64) 별 빌드
; https://www.sysnet.pe.kr/2/0/963




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

[연관 글]






[최초 등록일: ]
[최종 수정일: 10/15/2017]

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

비밀번호

댓글 작성자
 




... 91  92  93  94  95  96  97  98  99  100  101  102  103  [104]  105  ...
NoWriterDateCnt.TitleFile(s)
11038정성태9/9/201617191VC++: 99. 서로 다른 프로세스에서 WM_DROPFILES 메시지를 전송하는 방법파일 다운로드1
11037정성태9/8/201620437.NET Framework: 603. socket - shutdown 호출이 필요한 사례파일 다운로드1
11036정성태8/29/201617493개발 환경 구성: 297. 소스 코드가 없는 닷넷 어셈블리를 디버깅할 때 지역 변숫값을 확인하는 방법
11035정성태8/29/201613539오류 유형: 354. .NET Reflector - PDB 생성 화면에서 "Clear Store"를 하면 "Index and length must refer to a location within the string" 예외 발생
11034정성태8/25/201617182개발 환경 구성: 296. .NET Core 프로젝트를 NuGet Gallery에 배포하는 방법 [2]
11033정성태8/24/201615056오류 유형: 353. coreclr 빌드 시 error C3249: illegal statement or sub-expression for 'constexpr' function
11032정성태8/23/201614474개발 환경 구성: 295. 최신의 Visual C++ 컴파일러 도구를 사용하는 방법 [1]
11031정성태8/23/201611586오류 유형: 352. Error encountered while pushing to the remote repository: Response status code does not indicate success: 403 (Forbidden).
11030정성태8/23/201613351VS.NET IDE: 111. Team Explorer - 추가한 Git Remote 저장소가 Branch에 보이지 않는 경우
11029정성태8/18/201619820.NET Framework: 602. Process.Start의 cmd.exe에서 stdin만 redirect 하는 방법 [1]파일 다운로드1
11028정성태8/15/201614825오류 유형: 351. Octave 설치 시 JRE 경로 문제
11027정성태8/15/201615691.NET Framework: 601. ElementHost 컨트롤의 메모리 누수 현상
11026정성태8/13/201616324Math: 19. 행렬 연산으로 본 해밍코드
11025정성태8/12/201614869개발 환경 구성: 294. .NET Core 프로젝트에서 "Copy to Output Directory" 처리 [1]
11024정성태8/12/201615272오류 유형: 350. "nProtect GameMon" 실행 중에는 Visual Studio 디버깅이 안됩니다! [1]
11023정성태8/10/201616101개발 환경 구성: 293. Azure 구독 후 PaaS 서비스 만들어 보기
11022정성태8/10/201616446개발 환경 구성: 292. Azure Cloud Service 배포시 사용자 정의 작업을 추가하는 방법
11021정성태8/10/201614154오류 유형: 349. System.Runtime.Remoting.RemotingException - Type '..., ..., Version=..., Culture=neutral, PublicKeyToken=null' is not registered for activation [2]
11020정성태8/10/201615965VC++: 98. 원본과 대상 버퍼가 같은 경우 memcpy, wmemcpy 주의점
11019정성태8/10/201630882기타: 60. 도서: 시작하세요! C# 6.0 프로그래밍: 기본 문법부터 실전 예제까지 (2쇄 정오표)
11018정성태8/9/201616662.NET Framework: 600. 단일 메서드 내에서의 할당으로 알아보는 자바와 닷넷의 GC 차이점 [1]
11017정성태8/9/201619771웹: 33. HTTP 쿠키에 한글 값을 설정하는 방법
11016정성태8/7/201616693개발 환경 구성: 291. Windows Server Containers 소개
11015정성태8/7/201615049오류 유형: 348. Windows Server 2016 TP5에서 Windows Containers의 docker run 실행 시 encountered an error during Start failed in Win32
11014정성태8/6/201616008오류 유형: 347. Hyper-V Virtual Machine Management service Account does not have permission to open attachment
11013정성태8/6/201626447개발 환경 구성: 290. Windows 10에서 경험해 보는 Windows Containers와 docker [4]
... 91  92  93  94  95  96  97  98  99  100  101  102  103  [104]  105  ...