加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

msbuild – SlowCheetah没有在构建时转换web.config

发布时间:2020-12-14 18:35:10 所属栏目:资源 来源:网络整理
导读:我通过nuget安装了SlowCheetah软件包,并为我的web.config添加了基于Build config的转换文件. 但是,在构建时,web.config不会被转换.我检查了我的项目文件,确实看到了SlowCheetah PropertyGroup和Import元素的条目.我没有在项目文件中看到转换目标. 如果我添加
我通过nuget安装了SlowCheetah软件包,并为我的web.config添加了基于Build config的转换文件.
但是,在构建时,web.config不会被转换.我检查了我的项目文件,确实看到了SlowCheetah PropertyGroup和Import元素的条目.我没有在项目文件中看到转换目标.
如果我添加app.config,app.config文件确实会被转换.
我的理解是,安装SlowCheetah软件包应该自动将web.config转换目标添加到项目的MSBuild文件中.我可以手动添加它,但我认为SlowCheetah开箱即用.
我错过了什么.请告诉我.
我的要求是我的web.config文件应该根据构建配置进行转换,转换后的web.config文件应该位于输出目录中.
谢谢,感谢所有的帮助.

解决方法

只有在使用发布功能部署项目时,Visual Studio才会进行转换.要在进行构建时执行此操作,您需要调整MSBuild脚本.完整的解决方案是 here.这里的要点是:

Files in project Create a file named Web.Base.config,besides the
existing Web.Debug.config and Web.Release.config. This file will be
the equivalent to your old Web.config,as it will be the base for the
tranformation. You will end up with these files:

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>

UPDATE: From a reminder in the comments I realized that I also have a
problem with Visual Studio transforming the XML twice,when Publishing
a project. The solution to this is to add a Condition to the
Target-tag like this:

<Target Name="BeforeBuild" Condition="'$(PublishProfileName)' == '' And '$(WebPublishProfileFile)' == ''">

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读