重命名Web.config来运行转换可以打破nuget包的安装 [英] Renaming Web.config to run transforms breaks nuget package installation

查看:158
本文介绍了重命名Web.config来运行转换可以打破nuget包的安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的场景,我有我的Web.config,然后一个Web.Release.config,当我部署到生产我想用来转换Web.config。只有在VS中发布变换才能自动运行,而且我没有使用VS进行部署,我使用外部源代码控制以及巡航控制来构建和部署。



我已经看到了几个解决这个问题的解决方案:



1)使用基本的web.config文件Web.base.config),以便在构建过程中可以通过修改项目文件覆盖Web.config文件。
2)安装一个扩展,处理这个
3)在巡航控制中导入目标,并且基本上做同样的事情#1手动运行转换,但这仍然需要一个基本的配置文件与目的地分开web.config



所有这些问题都是我必须重命名我的web.config(例如到Web.base.config),或者我必须移动web配置到不同的目录,所以一旦发生转换,它不会覆盖我的基础(原始)web.config。



如果我这样做,那么当我安装/更新修改web.config的任何nuget软件包时,它会将更改添加到Web.config中,这些更改将每次被覆盖转换发生时,当更改真的需要应用于基本Web配置。



我已经搜索到任何地方,没有人提到这是一个问题。我错过了什么吗?我希望有人可以提供一个不需要原始Web.config文件名/位置来改变的解决方案。

解决方案

这是因为转换任务本身锁定web.config。



我相信最简单的解决方案是在转换之前使用复制任务并将其复制到web.config.copy。然后将您的web.config.copy转换为web.config.transformed,然后将其复制回web.config。



复制任务可以重写只读,所以你不应该在源控制文件中有任何问题


I have a simple scenario where I have my Web.config and then a Web.Release.config that I want to use to transform the Web.config when I deploy to production. Transforms only automatically run if you publish within VS, and I am not using VS for deployment, I'm using outside source control along with cruise control to build and deploy.

I've seen several solutions to this problem:

1) use a base web.config file (Web.base.config) so that the Web.config file can be overwritten during the build process by modifying the project file. 2) install an extension that handles this 3) within cruise control import the targets and essentially do the same thing as #1 manually running the transform, but this still requires a base config file separate from the destination web.config

The issue with all of these is that I have to rename my web.config (eg. to Web.base.config) or I have to move the web config to a different directory so that once the transform occurs it doesn't overwrite my base (original) web.config.

If I do this, then when I install/update any nuget packages that modify the web.config, it will add the changes to Web.config which will be overwritten everytime the transform occurs, when the changes really need to be applied to the base web config.

I've searched everywhere and noone has mentioned this as an issue. Am I missing something? I'm hoping someone can offer a solution that doesn't require the original Web.config filename/location to change.

解决方案

It's because transformation task itself locks web.config.

I believe the simplest solution would be to use copy task and copy your config to web.config.copy before transformation. Then transform your web.config.copy to web.config.transformed and then just copy it back into web.config.

Copy task can overwrite readonly so you shouldn't have any problems with source-controlled files

这篇关于重命名Web.config来运行转换可以打破nuget包的安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆