Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9703

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

$
0
0

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>

Viewing all articles
Browse latest Browse all 9703

Trending Articles