在大型 VS 解决方案中自动添加引用 [英] automate adding references in large VS solution

查看:33
本文介绍了在大型 VS 解决方案中自动添加引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 100 多个 C# 项目开发 VS 解决方案.我目前正在将它从 VS 2008 迁移到 VS 2010.有一些工作要做,因为很多项目使用 Enterprise Library 4(必须升级到 5.0)和 WCSF 2008(必须升级到 SCSF2010).我正在阅读 SCSF 升级说明,其中一个涉及执行此操作:

I'm working on a VS solution with 100+ projects in C#. I'm currently migrating it from VS 2008 to VS 2010. There is some work to be done because a lot of the projects use Enterprise Library 4 (which has to be upgraded to 5.0) and WCSF 2008 (which has to be upgraded to SCSF 2010). I'm going through the SCSF upgrade instructions, and one involves doing this:

添加对以下内容的引用服务位置装配在每个有一个引用的项目企业库程序集.

Add a reference to the following Service Location assembly in each project that has a reference to an Enterprise Library assembly.

Microsoft.Practices.ServiceLocation.dll

Microsoft.Practices.ServiceLocation.dll

有没有办法不通过 IDE 来做到这一点?我的意思是,打开 100 多个项目中的每一个,然后检查引用,然后在必要时添加引用,这是一种方法,但有没有更快的方法?我正在考虑对项目文件进行搜索以获取特定参考,然后在找到时进行插入.

Is there any way to do this without going through the IDE? I mean, opening up each of 100-odd projects, then checking the references, then adding a reference if necessary, is one way of doing it, but is there a faster way? I was thinking along the lines of doing a search over the project files for a particular reference, then doing an insert if it was found.

如果您以前做过这种事情,我们将非常欢迎您提出建议.谢谢.

If you've done this kind of thing before, suggestions would be very welcome. Thanks.

推荐答案

如果您想通过 IDE 执行此操作,可以使用 VSProject.References 根据需要添加/删除引用.

If you want to do this through the IDE, you can write a macro using VSProject.References to add/remove references as necessary.

但是,C# 项目文件 (.csproj) 只是 XML,因此您可以编写一个简单的实用程序,使用标准 XML 类根据需要调整文件.

However, C# project files (.csproj) are just XML, so you may be able to write a simple utility that can adjust the file as necessary using the standard XML classes.

这篇关于在大型 VS 解决方案中自动添加引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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