visual studio - Using transformed Web.config with IIS Express during debug -
i have visual studio application has multiple solution configurations. there web.config transform file each configuration. example, web.debug.config, web.release.config, etc.
we have couple of developers working on project have nonstandard sql express instance names due way installed sql express , rather having them continually editing web.debug.config run in environment have setup solution configuration each of them , added following bottom of .csproj file. code work in triggers creation of web.config , mywebapp.dll.config in vs /obj/debug-developername/ folder.
the transformed .config files perfect, iis express still uses root web.config (not transformed).
is there way iis express use these transformed web.config files while debugging locally?
<usingtask taskname="transformxml" assemblyfile="$(msbuildextensionspath)\microsoft\visualstudio\v12.0\web\microsoft.web.publishing.tasks.dll" /> <target name="aftercompile" condition="exists('web.$(configuration).config')"> <!-- generate transformed config in intermediate directory --> <transformxml source="web.config" destination="$(intermediateoutputpath)$(targetfilename).config" transform="web.$(configuration).config" /> </target>
using web application's web.debug.config works of us, not all.
there must way of getting iis express use transformed web.debug-developername.config during local debug?
does transformed web.config have copied different folder?
i faced problem before , found solution. unfortunately, solution not based on forcing iis use different name of config, if follow steps below, select configuration , run app (which ewhat need think). web.config transform occur before build , replace original web.config transformad one. then, when deployment (to local iis express) begins, use transformed one.
here step step how did in 1 project (vs2012):
- right click on project , select unload
- right click on again , select edit
- go bottom of file , append follwing right on "" tag (it last item)
<import project="$(msbuildextensionspath32)\microsoft\visualstudio\v$(visualstudioversion)\webapplications\microsoft.webapplication.targets" /> <target name="beforebuild" condition="'$(publishprofilename)' == '' , '$(webpublishprofilefile)' == ''"> <transformxml source="web.config" transform="web.$(configuration).config" destination="web.config" /> </target>
the condition there prevent duplicate transformation when publishing.
- save file, right click on , select reload
now, everytime run build, web.config transformed according selected configuration.
Comments
Post a Comment