简体   繁体   English

发布时TransformXml Web.config

[英]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. 我正在尝试使用TransformXml任务来获取一次性转换的所有配置,而不管在visual studio中选择的构建配置。 I'm able to accomplish it by editing the .csproj file and here is it. 我能够通过编辑.csproj文件来完成它,就在这里。

    <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. 当心MSBuild和VSBuild DO不同。 Afterpublish is VERY limited 发布后非常有限

Try having msbuild save the emitted sln Also here . 尝试让msbuild保存发出的sln也在这里

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. 在transformxml调用之前添加<message importance="high" text="Doing Custom Transform" /> ,然后在此调用之后添加另一条带有不同文本Finished Custom Transform消息。 This post speaks directly to your desire to do things involving the specialized publishing targets. 这篇文章直接说明了您希望做出涉及专业出版目标的事情。

General msbuild debugging information: 一般msbuild调试信息:

Hopefully this behavior IS msbuild dependant instead of VSBuild, since the two build processes differ. 希望这种行为是依赖于msbuild而不是VSBuild,因为两个构建过程不同。 If you are in luck and this is following the same behavior as MSBuild would follow the msbuild debugging process: 如果您运气好,并且遵循与MSBuild相同的行为,则遵循msbuild调试过程:

As with any magical behavior in msbuild, in your CSProj file look for any import target= code and go find those files. 与msbuild中的任何神奇行为一样,在您的CSProj文件中查找任何import target= code并查找这些文件。 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 您也可以将VS的调试器附加到您的构建过程 - 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 另外还要暂时提高构建详细程度http://blogs.msdn.com/b/msbuild/archive/2005/09/29/475157.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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