开发者

Visual Studio 2005 Project Build Order without using Project Dependencies

The short version of my question is how do I ch开发者_开发知识库ange the build order of projects in my solution without being forced to set one project as a dependency of the other?

In my solution, I've got 2 projects:

1.) An executable written in C

2.) A static library containing unit tests using the CUTest framework.

I've got 4 build configurations:

1.) Debug - I want only the exe in debug mode. The static lib project is un-selected so it won't build.

2.) Release - I want only the exe in release mode. The static lib project is un-selected so it won't build.

3.) Debug with Unit Tests - Want the static lib built, then the exe since it depends on the lib in this case.

4.) Release with Unit Tests - Ditto #3, just in release.

Because the executable is dependent on other libs and dlls not in the solution, I've got all those listed out as additional dependencies in the linker settings. In the unit test build configurations, I've got the static lib also included in the executable's dependency list.

Now here's the rub. The only way I've found so far to change the build order and make sure that the static lib is built before the exe is to right-click on the solution and select build order. In that dialog box, it says that I must use the dependencies tab to change the build order. This makes sense. However, if I mark the executable as depending on the static lib, it automatically adds the static library as a linker dependency of the executable. This is fine for the unit test build configs. In the non unit test build configs, however, it tries to link in the static lib which, if I've done a clean before the build, has been deleted and can't be linked in because I don't build it in those configs (nor do I want it linked in in those cases).

That being said, is there a way to change the build order without marking dependencies? I'd want to set the build order for the unit test configs to make sure the static lib was built first.


You can disable the automatic inclusion of library dependencies.

In your exe's property page:

Linker -> General -> Link Library Dependencies -> No

This allows you to specify project dependencies and thus build order without the static library being linked in.


I would take a look at NAnt. It may be possible to build an ant script to solve your problem.

http://nant.sourceforge.net


'Per configuration dependencies' may be an answer. It will allow to specify that the lib is a dependency of the executable for only the configuration where this makes sense.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜