2017-01-28 1 views
0

Window FormsWPF과 같은 다른 C# 프로젝트에서는 빌드 된 exe를 .net을 사용하여 다른 환경으로 복사하고 오류없이 실행할 수 있습니다.dll과 내용을 monogame에 exe에 포함

그러나 MonoGame에서 exe 파일에는 많은 dll이 필요하며 성공적으로 실행하려면 콘텐츠 폴더가 필요합니다.

exe ​​안에 dll과 내용을 포함시키는 방법이 있습니까?

답변

0

실제로 2 단계로 달성 할 수 있습니다.

  1. dll 포함.
  2. 내용을 포함합니다. DLL이

    이 임베딩

용이 NuGet을 사용 Costura.Fody을 설치함으로써 달성 될 수있다.

형 패키지 관리자 콘솔

Install-Package Costura.Fody 

소스에 다음 행 : Embedding DLLs in a compiled executable. 당신의 Content 폴더에

  1. 가 컴파일 된 콘텐츠 파일 (.xnb 파일 및 기타 내용)을 복사 내용을 포함

    .

  2. 프로젝트 속성 페이지로 이동하여 컴파일 된 콘텐츠 파일을 리소스에 추가하십시오.
  3. 아래의 코드를 바꿉니다 :

    public Game1() 
    { 
        graphics = new GraphicsDeviceManager(this); 
        Content.RootDirectory = "Content"; 
    } 
    

    public Game1() 
    { 
        graphics = new GraphicsDeviceManager(this); 
        ResourceContentManager resxContent; 
        resxContent = new ResourceContentManager(Services, Resources.ResourceManager); 
        Content = resxContent; 
    } 
    
  4. 완료와 함께! Loading Content Within a Game Library

    : 이제 기존의 방법

    Content.Load<Texture2D>("Image1"); 
    

소스를 사용하여 내용을로드 할 수 있습니다