简体   繁体   中英

TransformXml Web.config while publishing

I'm trying to use the TransformXml task to get all the config transformed at one shot irrespective of the build configuration that is selected in visual studio. I'm able to accomplish it by editing the .csproj file and here is it.

    <UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Target Name="TransformWebConfig"  AfterTargets="AfterPublish">
    <TransformXml Source="$(SolutionDir)WCFServices\Web.config" 
              Transform="$(SolutionDir)WCFServices\Web.Release.config" 
              Destination="$(OutDir)WebRelease.config" 
              StackTrace="true" />
</Target>

The problem here is while I do a publish, the transformed config files gets placed in the output dir but this happens before the delete operation. I would need the configs to be transformed after the delete operation.

Please advise?

Beware MSBuild and VSBuild DO differ. Afterpublish is VERY limited

Try having msbuild save the emitted sln Also here .

Have you verified the file is getting transformed at the expected time? Add in a <message importance="high" text="Doing Custom Transform" /> before your transformxml call, then another message with different text Finished Custom Transform after this call. This post speaks directly to your desire to do things involving the specialized publishing targets.

General msbuild debugging information:

Hopefully this behavior IS msbuild dependant instead of VSBuild, since the two build processes differ. If you are in luck and this is following the same behavior as MSBuild would follow the msbuild debugging process:

As with any magical behavior in msbuild, in your CSProj file look for any import target= code and go find those files. Following these through will lead you to the part that is making the decision about any of this.

Also you can attach VS's debugger to your build process - http://blogs.msdn.com/b/visualstudio/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx + http://blogs.msdn.com/b/visualstudio/archive/2010/07/09/debugging-msbuild-script-with-visual-studio-2.aspx

Determining build order

Also in crank up the build verbosity temporarily http://blogs.msdn.com/b/msbuild/archive/2005/09/29/475157.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM