c# - App.config replacements for unit tests -
my continuous integration server (teamcity) configured run unit tests in our app on build. prior running tests, need change of appsettings make them valid our ci server. i'm achieving similar web project using deployment project provided visual studio. can same test project?
thanks, gonzalo
it's possible use web.config transformations app.config files through workaround.
you have invoke appropriate msbuild tasks @ right stage in build process.
add code snippet project file:
<usingtask taskname="transformxml" assemblyfile="$(msbuildextensionspath32)\microsoft\visualstudio\v10.0\web\microsoft.web.publishing.tasks.dll" /> <target name="aftercompile" condition="exists('app.$(configuration).config')"> <!-- generates transformed app.config in intermediate directory --> <transformxml source="app.config" destination="$(intermediateoutputpath)$(targetfilename).config" transform="app.$(configuration).config" /> <!-- forces build process use transformed configuration file --> <itemgroup> <appconfigwithtargetpath remove="app.config"/> <appconfigwithtargetpath include="$(intermediateoutputpath)$(targetfilename).config"> <targetpath>$(targetfilename).config</targetpath> </appconfigwithtargetpath> </itemgroup> </target>
then add additional app.config files project each build configuration wish apply transformation. example:
<itemgroup> <none include="app.config" /> <none include="app.release.config"> <dependentupon>app.config</dependentupon> </none> </itemgroup>
related resources:
Comments
Post a Comment