简体   繁体   English

如何对引用执行“查找和替换”?

[英]How can I perform 'find and replace' on references?

Our solution has several (10+) C# projects. 我们的解决方案有几个(10+)个C#项目。 Each has a reference to the CAB extension library, with the reference pointing to the DLLs in the library's release folders. 每个文件都有对CAB扩展库的引用,该引用指向库的发行文件夹中的DLL。 Each project has between four and seven such references. 每个项目都有四到七个这样的参考。

We'd like to make some changes to the library; 我们想对库进行一些更改; but to debug the changes, we'll need to build a debug version of the library and refer to that. 但是要调试更改,我们需要构建该库的调试版本并进行引用。 I'd like to add the library's projects to our solution and change each of the DLL references to a project reference. 我想将库的项目添加到我们的解决方案中,并将每个DLL引用更改为一个项目引用。

Is it possible to perform a 'find and replace' on the existing references, or will I have to do it by hand? 是否可以在现有参考文献上执行“查找并替换”,还是我必须手工完成?

There isn't such a feature in the VS IDE. VS IDE中没有这样的功能。

However, as a .csproj file is just an XML document it is possible to do such a global search and replace in a scripted fashion eg by changing one file to observe the before and after states then running sed over the remainder. 但是,由于.csproj文件只是XML文档,因此可以通过脚本方式进行这样的全局搜索和替换,例如,通过更改一个文件以观察前后状态,然后对其余部分运行sed

For a one-off, going to the extent of writing a script to load the XML and making the substitutions by DOM manipulation is probably overkill. 一次性来说,编写脚本来加载XML并通过DOM操作进行替换可能是过大的。

Take a look at Jared's answer to this SO thread . 看一看Jared对这个SO线程的回答。 That approach will likely work for you. 这种方法可能对您有用。

If you download CI Factory, it just so happens that there is a nant function in there called FixUpThirdPartyRefs which you could use or tweak to help you do this. 如果下载CI Factory,则恰好发生在其中有一个名为FixUpThirdPartyRefs的nant函数,您可以使用它或对其进行调整以帮助您完成此操作。 So you could just setup nant and use that function. 因此,您可以只设置nant并使用该功能。

It is part of the power tools with CI Factory: http://www.cifactory.org/joomla/index.php?option=com_content&task=view&id=29&Itemid=41 它是CI Factory电动工具的一部分: http : //www.cifactory.org/joomla/index.php? option=com_content&task=view& id= 29&Itemid= 41

Why don't you just replace DLLs in library's release folder with debug version temporary ? 为什么不只用临时调试版本替换库的发行文件夹中的DLL? I assume that you have local development environment. 我假设您具有本地开发环境。

EDIT: You could: 1. develop all time with debug version of library 2. make updating references in *.csproj more flexible 3. make file system location of library files more flexible 编辑:您可以:1.始终使用库的调试版本进行开发2.使* .csproj中的更新引用更灵活3.使库文件的文件系统位置更灵活

On point 3: If the path to your library dlls contains "release" and if debug and release library folder structure is the same than change from release could be made by just renaming folder "release" to "release.original" and "debug" to "release". 关于第3点:如果库dll的路径包含“ release”,并且如果调试库和发布库的文件夹结构相同,则只需将文件夹“ release”重命名为“ release.original”和“ debug”即可进行从release的更改。以“释放”。

I would probably choose option 1 and all time develop with debug assemblies. 我可能会选择选项1,并且始终使用调试程序集进行开发。 Release build would use just for final testing and deploy to customer. 发布版本仅用于最终测试并部署到客户。 Debug and release dlls are not that different. 调试和发布dll没什么不同。

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

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