简体   繁体   English

生成的Visual Studio 2008 XDT(配置转换)

[英]Visual Studio 2008 XDT (Config Transform) on build

I'm maintaining a webforms application for several different clients in Visual Studio 2008. Each client has their own separate web.config file. 我在Visual Studio 2008中为几个不同的客户端维护一个webforms应用程序。每个客户端都有自己的单独的web.config文件。 We are using config transformation when deploying which works great. 部署时我们正在使用配置转换,效果很好。

There are many developers currently working on this project, and while developing each developer needs to have the configuration values for a specific client. 当前有许多开发人员在从事此项目,并且在开发过程中,每个开发人员都需要具有特定客户端的配置值。 Right now, what we are doing is that each one of us, has their own version of web.config locally, and we just try to be careful not to check in the web.config file. 现在,我们正在做的是每个人在本地都有自己的web.config版本,我们只是要小心不要检入web.config文件。

This approach of course has several drawbacks. 这种方法当然有几个缺点。 We need to do this manually, which is annoying, we need to be really careful not to check in the config files since it could cause trouble for the rest of the developers, it's cumbersome to add a new value to the config, etc. 我们需要手动执行此操作,这很烦人,我们需要非常小心,不要检入配置文件,因为这可能会给其他开发人员造成麻烦,并且在配置中添加新值也很麻烦。

I'd like to transform the config files when building from visual studio, so we can chose which file to take the configuration values from, without having to manually edit web.config. 从Visual Studio构建时,我想转换配置文件,因此我们可以选择从哪个文件中获取配置值,而无需手动编辑web.config。

I've been looking in the web for a while, but the best thing i found so far is this: http://www.codeproject.com/Articles/399002/Project-Build-Web-config-transformation 我已经在网上寻找了一段时间,但是到目前为止,我发现最好的东西是: http : //www.codeproject.com/Articles/399002/Project-Build-Web-config-transformation

Which is not working for me, it gives me a build error saying it can't copy Web.config_output because the file is missing. 这对我不起作用,它给我一个生成错误,说它由于文件丢失而无法复制Web.config_output。

By default tools like SlowCheetah and other config transform technologies use the $(Configuration) to figure out the name of the transformation to apply. 默认情况下,诸如SlowCheetah和其他配置转换技术之类的工具使用$(Configuration)来确定要应用的转换的名称。 You could take the slowcheetah.targets file and edit it to take $(username) which will pick up the standard windows logged on user name if you're building inside visual studio. 您可以使用slowcheetah.targets文件并将其编辑为$(username) ,如果您是在Visual Studio中构建的,它将使用登录用户名的标准窗口。 You could use a condition to apply the change specifically when '$(BuildingInsideVisualStudio)'='true' . 您可以使用条件专门在'$(BuildingInsideVisualStudio)'='true'时应用更改。

This will require you to do some work with MsBuild target files, but the end result would be that your developers can check in a web.jesse.houwing.config (in my case) and that of that file is there, their transformation will be applied instead of the standard release or debug transformation. 这将需要您对MsBuild目标文件进行一些工作,但是最终结果是您的开发人员可以检入web.jesse.houwing.config (在我的情况下),并且该文件在那里,它们的转换将是应用而不是标准版本或调试转换。

As for a good starting point, look at SlowCheetah . 至于一个好的起点,请看SlowCheetah

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

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