Visual Studio生成/清除订单 [英] Visual Studio Build/Clean Order

查看:86
本文介绍了Visual Studio生成/清除订单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在Visual Studio 2005 Pro(C#)中有一个解决方案,其中包含一些项目.其中大多数是使用COM扩展现有应用程序(ArcGIS)的类库DLL.但是由于所有这些项目在很多方面都做相同的事情,因此我将一个共享库DLL作为其中一个项目包含在内. (和其他应用程序DLL之一,也与其他一些DLL共享一些东西.)VS非常聪明,知道所有其他项目都依赖于共享项目并以正确的方式构建事物命令.如果我先做一个干净的解决方案,然后再构建,那么它也将按照正确的顺序进行操作.
但是,如果您修改共享库并重新构建,它将无法正确处理.它似乎首先要重建共享库,因为它应该按应有的构建顺序排列.但是它不会首先清除其他项目,因此在构建这些项目时,它会首先尝试注销DLL并失败,因为DLL使用的共享库与预期的版本不存在. 无法取消注册程序集<应用程序dll>.无法加载文件或程序集"<共享的dll> ;、版本Xxx等."或其依赖项之一.系统找不到指定的文件. 如果我再次重建,它可以正常编译.因此,这不是主要问题.但是在每次构建之前必须进行清理,或者在经历这些错误并实际构建之前进行两次(有时是3次)构建,这很烦人.

当我对共享库进行更改时,我希望它会将依赖项目标记为也需要重新构建,并先清理它们,重新构建共享库,然后再构建依赖项.从共享开始,似乎一次只重建一个项目.如果我可以告诉它在任何构建中始终保持干净,我可能会很好.构建需要花费更长的时间,但至少我不会一直为此感到烦恼.有人对如何处理有任何建议吗?谢谢.

So I have a solution in Visual Studio 2005 Pro (C#) with a handful of projects in it. Most of them are Class Library DLLs using COM to extend an existing application (ArcGIS). But since there''s a lot of things that all of these projects do the same, I have a shared library DLL included as one of the projects. (And one of the other application DLLs, shares some of it''s stuff with some of the others as well.) VS is smart enough to know that all of the other projects are dependent on the shared project and builds things in the correct order. If I do a clean solution first and then build, it also does things in the correct order.

But, it doesn''t handle things correctly if you modify the shared library and re-build. It appears to rebuild the shared library first since it''s first in build order as it should be. But it doesn''t clean the other projects first so when those build, it first tries to unregister the DLL and fails since the shared library that DLL uses doesn''t exist with the version it expects. "Cannot unregister assembly <application dll>. Could not load file or assembly ''<shared dll>, Version X.x.x, etc..'' or one of its dependencies. The system cannot find the file specified." If I rebuild again it compiles fine. So it''s not a major problem. But it gets annoying having to do a clean before each build or build 2 sometimes 3 times before it gets through these errors and actually builds.

When I make a change to the shared library, I would expect it to mark the dependent projects as also needing to be rebuilt and clean them first, rebuild the shared library, then build the dependents. It seems to just rebuild each project one at a time starting with the shared. I would probably be fine if I could tell it to always clean on any build. It would take a little longer to build but at least I wouldn''t get bothered with this all the time. Anyone have any suggestions on how to deal with this? Thanks.

推荐答案

不能为所有内容设置预构建步骤(取消注册com对象),编译所有内容,然后进行后构建步骤
Can''t you set a pre-build step for everything (to unregister the com objects), compile everything, and then a post-build step that re-registers the com objects?


糟糕,我忘记了我已经实现了一些构建前/后构建步骤,实际上删除了共享库的所有实例.这会导致我的错误,即在注销时找不到共享库.所以我创造了我自己的问题.我在构建之前/之后的步骤中删除共享库的原因是因为共享库用于不同的项目/解决方案.如果我构建了一个而不是另一个,那么首先要加载的一个将加载共享库的版本,这将导致另一个项目无法正常工作.通过删除共享库,我确定不会出现此问题.现在,我已将大多数这些项目转移到一个解决方案下,Visual Studio可以处理重建,因此我不再遇到这个问题.感谢您让我指出正确的方向.
Ah crap, I had forgotten that I had already implemented some pre/post build steps which actually delete all instances of the shared library. Which then cause my errors where it can''t find the shared library when unregistering. So I created my own problem. The reason I was deleting the shared library in the pre/post build steps was because the shared library was used in different projects/solutions. If I built one but not the other, the one that happened to load first would load it''s version of the shared library which would then cause the other project to not work. By deleting the shared libraries, I was sure to not have this problem. Now that I''ve moved most of these projects under one solution, Visual studio can handle the rebuild so I shouldn''t have this problem anymore. Thanks for getting me pointed in the right direction.


这篇关于Visual Studio生成/清除订单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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