SlowCheetah不会在构建时转换web

SlowCheetah不会在构建时转换web

本文介绍了SlowCheetah不会在构建时转换web.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过nuget安装了SlowCheetah软件包,并基于Build config为我的web.config添加了转换文件.但是,在构建时,不会对web.config进行转换.我检查了我的项目文件,并确实看到了SlowCheetah PropertyGroup和Import元素的条目.我没有在项目文件中看到转换目标.如果我添加一个app.config,则app.config文件的确会转换.据我了解,安装SlowCheetah软件包应将web.config转换目标自动添加到该项目的MSBuild文件中.我可以手动添加它,但我认为SlowCheetah可以立即使用.我错过了什么吗?请让我知道.我的要求是,应根据构建配置对我的web.config文件进行转换,并且转换后的web.config文件应位于输出目录中.谢谢,感谢所有帮助.

I installed the SlowCheetah package via nuget and added transform files for my web.config based on Build config.However, on building, the web.config does not get transformed. I checked my project file and did see entries for SlowCheetah PropertyGroup and Import elements. I dont see a target for transformation in the project file.If I add an app.config, the app.config file does get transformed.It is my understanding that installing the SlowCheetah package should automatically add the web.config transform target to the MSBuild file for the project. I can add it manually but I thought SlowCheetah does it out of the box.Am I missing something. Please do let me know.My requirement is that my web.config file should get transformed based on build configuration and the transformed web.config file should be located in the output directory.Thanks and appreciate all help.

推荐答案

仅当您使用发布功能部署项目时,Visual Studio才会进行转换.为此,当您执行构建时,您需要调整MSBuild脚本.完整的解决方案是此处.这里是要领:

Visual Studio is doing Transformation only when you deploy your project by using the publish functionality. To do it when you do the build you need to tweak your MSBuild script. The complete solution is here. Here the essentials:

Web.config,Web.Base.config,Web.Debug.config,Web.Release.config和 Web.config.将以下配置添加到您的底部 .csproj文件,就在结束标记-

Web.config, Web.Base.config, Web.Debug.config, Web.Release.config, and Web.config. Add the following configuration to the bottom of your .csproj-file, just before the closing -tag:

<Target Name="BeforeBuild">
    <TransformXml Source="Web.Base.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
</Target>
<Target Name="BeforeBuild" Condition="'$(PublishProfileName)' == '' And '$(WebPublishProfileFile)' == ''">

这篇关于SlowCheetah不会在构建时转换web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 09:25