LoginSignup
1
1

More than 3 years have passed since last update.

[C#]DebugとReleaseで別々のconfigファイルを適用する

Posted at

config配下にApp.Debug.configとApp.Release.configを配置して、実行時にそれぞれ適用する際に詰まったので記録。

環境:
Windows10
VS express2017

こちらのサイトを参考にしました。

1. .csprojを開く

エクスプローラで該当の .csprojを表示し、メモ帳などで開く。

2. .csprojを編集する

2-1. PropertyGroupを編集

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>

の間に

<appConfig>App.Debug.config</appConfig>

を記入。DebugをReleaseに置き換えて同様に記入。

2-2. ItemGroupを編集

<None Include="App.config" />
<None Include="App.Debug.config" />
<None Include="App.Release.config" />

を以下に書き換える。(Releaseも同)


<ItemGroup>
 <Content Include="App.config">
  <SubType>Designer</SubType>
 </Content>
</ItemGroup>
<ItemGroup>
 <Content Include="App.Debug.config">
 <DependentUpon>App.config</DependentUpon>
  <SubType>Designer</SubType>
 </Content>
</ItemGroup>
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1