开发者

Why my web app doesn't use Web.Debug.config in debug running? [duplicate]

This question already has answers here: Closed 10 years ago.

Possible Duplicate:

Use Visual Studio web.config transform 开发者_运维知识库for debugging

I have an asp.net application with three web.config transformations.

Why my web app doesn't use Web.Debug.config in debug running? [duplicate]

I was thinking when I launch debug running (F5 with Debug mode selected) the transformations written in the Web.Debug.config will apply.. But it doesn't work.. the Web.config used is the "Base" one.

You will tell me : "The transformation aren't right".. But they are because when I make a deploy (right click/publish) with debug release config :

Why my web app doesn't use Web.Debug.config in debug running? [duplicate]

The rendered web.config have modifications! So it works, but the debug running is using the base web.config.. Is there a place I can configure that?


EDIT: Much more refined approach can be found on SO: Use Visual Studio web.config transform for debugging

I had commented that I too would like this feature but hadn't found a way to do it yet. Then decided to have a quick google.

A discussion here has lead me to one possible solution provided by cmac3095:

I don't mess with MSBUILD that much but my solution was to add a custom target to the XXX.Web.csproj that did the transform and then add a custom "Post build" event to the XXX.Web.csproj that invoked MSBUILD (to perform the transform) and an XCOPY to copy the transformed web.config over the original. One side effect is that, as we have TFS, it always contains the last web.config that was transformed which can be a bit usettling (you keep thinking one of your other developers has overwritten your settings - which, in a sense, they have ;-)....but, of course, your settings are in the web.xxxxxx.config you use in the transform. Okay, enough explanation.
Here's what you do: Copy and paste this into you XXXX.Web.csproj just above the commented out "Target Name="BeforeBuild" element...

<UsingTask TaskName="TransformXml"
 AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"
 />    <Target Name="Transform"> 
     <MakeDir Directories="obj\$(Configuration)"
 Condition="!Exists('obj\$(Configuration)')"
 /> 
     <TransformXml Source="Web.Config" Transform="Web.$(Configuration).config"
 Destination="obj\$(Configuration)\Web.config"
 StackTrace="true" />    </Target>   
 <Target Name="AfterBuild">   
 </Target>

That's it. On the next build of your xxx.web.config, the post build will run the custom target and generate transformed web.config. The XCOPY will overwrite the existing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜