简体   繁体   中英

Build C# Projects and their dependencies

In VS2005 I have a few C# projects that depend on each other.

If project A depends on B (eg references it), then I want B to build whenever I build A, assuming B has changed in some way since last built. That's the way it is with VC projects, but for some reason it doesn't seem to work with C# projects. If I clean B and then build A it just tells me that it can't find B...

Any ideas?

If you right-click on your Visual Studio Solution and choose "Project Build Order" you can verify the order in which those individual projects are being built. ALSO make sure that you aren't referencing a "debug" DLL in a "release" build and vice versa.

您需要构建实际的解决方案,而不是单独构建项目。

A Solution lets you define Dependencies between Projects. And if you use that, it should work automatically. Normally the dependencies are set up automatic too. Chances are you added a reference to the assembly, not the project. Watch the Projects tab in the Add reference dialog.

If you add all the projects to the same solution and set up the dependencies between them then Visual Studio should be able to work out the correct order and build everything that needs building when you change something in one of the "lower" projects.

In your case it would know that it had to rebuild B before building A.

override the target AfterResolveReferences in your csproj. Then use the item @(NonVCProjectReference) to list the path to every project and build them. I recommend you to read the MSBuild documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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