How to select different app.config for several build configurations

来源:互联网 发布:阿里云备案账号是什么 编辑:程序博客网 时间:2024/05/19 01:31

1. How to select different app.config for several build configurations

http://stackoverflow.com/questions/8082662/how-to-select-different-app-config-for-several-build-configurations?rq=1

You can try the following approach:

  1. Right-click on the project in Solution Explorer and select Unload Project.
  2. The project will be unloaded. Right-click on the project again and select Edit <YourProjectName>.csproj.
  3. Now you can edit the project file inside Visual Studio.
  4. Locate the place in *.csproj file where your application configuration file is included. It will look like:
    <ItemGroup>        <None Include="App.config"/>    </ItemGroup>
  1. Replace this lines with following:
    <ItemGroup Condition=" '$(Configuration)' == 'Debug' ">        <None Include="App.Debug.config"/>    </ItemGroup>    <ItemGroup Condition=" '$(Configuration)' == 'Release' ">        <None Include="App.Release.config"/>    </ItemGroup>

I have not tried this approach to app.config files, but it worked fine with other items of Visual Studio projects. You can customize the build process in almost any way you like. Anyway, let me know the result.

 

2. Calling methods from different Projects in one Solution

You need to add a reference to the 3rd project in your 1st project.  To do this, right-click on your project, select "Add Reference," then select the project in your solution.  Once your main project references the 3rd project, then you can access its public types.