개발 중인 프로젝트에서 상용 컴퍼넌트를 이용하다보니 제작한 라이브러리 포함하여 dll이 30개 정도 되었다.

 

고객님께서는 dll이 너무 많아 복잡하다며 실행 파일 한개만을 원하셨다.

 

 

 

제프리 리쳐 형님과 같이 동적으로 어셈블리를 로드할까 했는데....좀 더 검색해보았다.

 

 

AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {

    String resourceName = AssemblyLoadingAndReflection. +

        new AssemblyName(args.Name).Name + .dll;

    using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))

    {

        Byte[] assemblyData = new Byte[stream.Length];

        stream.Read(assemblyData, 0, assemblyData.Length);

        return Assembly.Load(assemblyData);

    }

}; 

참조 : https://blogs.msdn.microsoft.com/microsoft_press/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition/

 

 

 

 

결국 Costumra.Fody 를 찾게 되었다.

 

자동으로 exe 안에 라이브러리를 넣어준다. 압축까지 지원해준다.

 

Nuget을 통하여 설치하면 "FodyWeavers.xml" 파일이 생성된다.

 

해당 xml 파일을 이용해 정교한 설정이 가능하다. (압축여부, Debug심볼첨부여부 등등...)

 

https://github.com/Fody/Costura

 

 

 

 

 

압축하였을 때는 .zip 확장자로 exe 파일에 삽입되어있다.

 

[압축하지 않은 상태]

 

 

 

[압축한 상태]

'.Net > C#' 카테고리의 다른 글

C# 리플렉션을 이용한 Delegate 넘기기  (0) 2016.05.11
C# Undo Redo 기능 구현하기  (3) 2015.10.20
C# 원문자 구하기  (0) 2015.10.05
SerialPort Read Blocking 시키기  (0) 2015.08.05
문자열 비교 테스트 (대소문자 무시)  (0) 2015.07.02

+ Recent posts