Wanted to pick the brains of those MS Build/ VS Post build exponents here.
I would like to have my web.config entries customizable per user/machine/environment.
I could have my configurable/changeable entries marked in the web.config and would like those entries overridden by the respective user/environment file and would like to have an order that decides which entries should trump the other if the entry is found in multiple files.
for eg: web.config has a $connectionstring entry and the customization files per user/environment could have the potential values to replace $connectionstring depending on the context/configuration the solution is built
which means, I could have a set of files like below:
user_joe.config
$connectionstring = db_where_joe_like_to_connect_to
staging.config
$connectionstring = db_where_staging_connect_to
production.config
$connectionstring = db_production
so if joe is compiling the solution from his Dev box, the web.config should have the value "db_where_joe_like_to_connect_to" for $connectionstring.
I am hoping there could be a solution that doesn't involve Nant.
hope someone can throw pointers.
Each of the settings in the web. config file appear in the Application settings area of this dialog box. To change a value, click it, then click Edit. In the Edit/Add Application Settings dialog box, type the new value, then click OK.
config file is located in the %SystemRoot%\Microsoft.NET\Framework\%VersionNumber%\CONFIG\ folder. The default settings that are contained in the Machine. config file can be modified to affect the behavior of Microsoft . NET applications on the whole system.
In Solution Explorer, right-click your Web site name, and then click Add New Item. In the Templates window, click Web Configuration File. The file name in the Name text box should be Web. config.
You can use visual studio 2010's web.config transform settings.
http://weblogs.asp.net/gunnarpeipman/archive/2009/06/16/visual-studio-2010-web-config-transforms.aspx
This will allow each developer to have their portion of a web.config that can get merged in for their build settings.
Internally we use an event that was pieced together from various places on the net- since normally this happens during publishing and we wanted it to happen at compile time.
Add a BeforeBuild target So - from the csproj file:
<Target Name="BeforeBuild"> <TransformXml Source="$(SolutionDir)Web.config" Transform="$(SolutionDir)Web.$(Configuration).config" Destination="$(SolutionDir)Web.$(Configuration).config.transformed" /> </Target> <PropertyGroup> <PostBuildEvent>xcopy "$(SolutionDir)Web.$(Configuration).config.transformed" "$(SolutionDir)Web.config" /R /Y</PostBuildEvent> </PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With