2011-07-28 19 views
0

私は現在、解決策を公開するためのmsbuildスクリプトを作成していますが、これはすべて問題ありませんが、選択されている設定に応じて別のapp.configを使いたいと思っています。msbuildは別のapp.configで公開します

  • 私は、人々がトランスフォームについて話を見てきましたが、これはネイティブにのみはいあなたは少しハッキングとはapp.configのためにそれを行うことができます(web.configファイルのために動作しますが、公開タスクのために動作するようには思えませんon msbuild)

  • Creating msbuild script to build, publish with specified app.config, and update from different locations 私もこの投稿を見ましたが、この特定の質問には実際には答えません。

現在、私のビルドスクリプトは次のようになります。このスクリプトが実行されたときに

<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 targetを実行する前にファイルを書き換えて、新しいターゲットを導入してターゲットの依存関係を作成することができます。

+0

app.configを編集することをお勧めしますか?構成設定に応じて1)設定を確認する(デバッグまたはリリース)2)app.configを新しい変数で編集する3)公開タスクを実行しますか? – Mike

+0

編集しないで、出力フォルダに右のものをコピーしてください。そうすれば、PublishAppタスクはあなたがコピーしたばかりのファイルを取り込みます。したがって、debugConfig.configまたはreleaseCOnfig.configから/rightpath/app.configにコピーするだけです – sll

関連する問題