2011-07-28 3 views
0

현재 솔루션을 게시하기 위해 msbuild 스크립트를 작성하고 있지만 괜찮 았지만 어떤 구성을 선택했는지에 따라 다른 app.config를 사용하려고합니다.msbuild가 다른 app.config로 게시합니다.

  • 나는 사람들이 변환에 대해 이야기를 본 적이 있지만이 기본적으로 단지 네 조금 해킹과의 app.config을 위해 그것을 할 수 있습니다 (Web.config를 위해 작동하지만 게시 작업을 위해 작동하지 않는 것)

  • Creating msbuild script to build, publish with specified app.config, and update from different locations )은 MSBuild에 나는 또한이 게시물을 본 적이 있지만 실제로 링크를 읽은 후 (이 특정 질문에 대답하지 않습니다.

    <PropertyGroup> 
        <ProjectFile>.\BarcodeScannerApp\BarcodeScannerApp.csproj</ProjectFile> 
        <SolutionFile>.\BarcodeScannerApp.sln</SolutionFile>   
        <PublishLoc>http://publishlocation.com</PublishLoc> 
        <Configuration>release</Configuration> 
        <GenerateManifests>false</GenerateManifests> 
        <BootstrapperEnabled>true</BootstrapperEnabled> 
        <ApplicationVersion>1.0.0.*</ApplicationVersion> 
        <UpdateEnabled>true</UpdateEnabled> 
        <UpdateMode>Foreground</UpdateMode> 
        <UpdateUrl>http://backoffice-dev/</UpdateUrl> 
    </PropertyGroup> 
    
    <Target Name="PublishApp">  
    
        <MSBuild Projects="$(SolutionFile)" 
          Targets="Publish"    
          Properties="PublishUrl=$(PublishLoc); 
          Configuration=$(Configuration); 
          GenerateManifests=$(GenerateManifests); 
          BootstrapperEnabled=$(BootstrapperEnabled); 
          ApplicationVersion=$(ApplicationVersion); 
          UpdateEnabled=$(UpdateEnabled); 
          UpdateMode=$(UpdateMode); 
          UpdateUrl=$(UpdateUrl)" 
        /> 
    
    </Target> 
    
    이 스크립트가 실행되는 현재

    , 그것은 복사본이 파일 BarcodeScannerApp.exe.config를 생성처럼

현재 나의 빌드 스크립트 보인다 app.config 내가 솔루션에 있습니다. 다른 설정 파일 (Debug/Release)에 따라 다른 설정 파일을 사용하고 싶습니다. 적절한 하나를 선택하고 대상 디렉토리

<When Condition="'$(Configuration)'=='DEBUG'"> 
    ... 
</When> 

<When Condition="'$(Configuration)'=='RELEASE'"> 
    ... 
</When> 

에 다시 WHEN를 사용하여 다음

<DebugConfig>...</DebugConfig> 
<ReleaseConfig>...</ReleaseConfig> 
<TargetConfigPath>...</TargetConfigPath> 

그리고 :

답변

1

으로 먼저처럼 모든 설정 파일에 대한 app.config 경로를 참조하는 속성을 정의해야합니다 새 대상을 도입하고 대상 종속성을 작성하여 PublishApp 대상을 실행하기 전에 파일을 다시 쓸 수 있습니다.

+0

app.config를 수정 하시겠습니까? 구성 설정에 따라 다릅니 까? 1) 구성 확인 (디버그 또는 릴리스) 2) app.config를 새 변수로 편집 하시겠습니까? 3) 게시 작업을 실행 하시겠습니까? – Mike

+0

편집하지 말고 오른쪽 폴더를 출력 폴더로 복사하면 PublishApp 작업은 방금 복사 한 파일을 가져옵니다. 따라서 debugConfig.config 또는 releaseCOnfig.config에서 /rightpath/app.config로 복사하면됩니다. – sll

관련 문제