I have an application with many projects. I sometimes find I have to delete the dlls and recompile each project before I get an overall clean compile. I also find when i do a build I have to remember to checkout the dlls of each project which are stored in the bin folder, compile each project, check in the dll and then run the build to get a clean compile. This is cumbersome. I just want to rebuild once for any changes I make, and when I make a release. So how do I sort this out?
-
1+1 for this awesome question... – Bhushan Firake Feb 13 '13 at 15:46
-
I'm not sure I understand. I have many solutions with many projects that contain mixed third party and homegrown DLLs and never have the issues that you are talking about. You shouldnt have to "checkout" static DLLs to compile unless you are making changes to those DLLs. If you are making changes to the DLLs why are you referencing the DLLs directly rather than as project references? – jmrnet Feb 13 '13 at 16:00
-
The third party dlls are in a lib folder and that is not a problem. I found that in order to compile my application, I had to copy the dlls of each project into the bin directory of my main project. Maybe there is another better way of doing this? I suspect there is. – arame3333 Feb 13 '13 at 16:04
3 Answers
It's hard to know exactly what you need to fix your specific problems without more details, but these tips should help a lot.
when i do a build I have to remember to checkout the dlls of each project which are stored in the bin folder
First of all, do not store your bin folder contents in source control. Instead, publish a build only when you need to share it with someone, and put it in a different place in your source control system. Here's an example of a folder structure that would work that way.
-MyProduct --main ----src ----bin << not checked in ----etc... -Distribution --MyProject ----release number ------explicitly published dlls
I have to delete the dlls and recompile each project before I get an overall clean compile.
Sometimes this happens. Use the Rebuild Solution command in Visual Studio.
A problem that can cause this to happen more frequently is if you use file references instead of project references. Use project references. See this question for details on that:
Project Reference Vs File Reference?
If you can't use project references for some reason, you can manually change the build order of the solution, and setup dependencies between projects for better updating.
-
When I remove the project dlls from source control in the bin directory, the release build falls over as it cannot find them. I know I ought to give you some more information to go on, but I can't think what. – arame3333 Feb 13 '13 at 16:32
-
So, you need to solve that problem. Your release build should not depend on dlls being checked in to your build. It is incredibly likely that you will have to "peel the onion" on this problem a couple of times. – tallseth Feb 13 '13 at 17:54
We had this problem in the company I work for and we're still trying to clean it all up.
The first recommendation I'd make is don't have Project References to common libraries in your solutions. You said you have some inhouse dlls in the bin folder of your project. You need to ask yourself:
- Are these dlls specific to this solution
- Or, are they common libraries you will use again
If it's the former, then I suggest you have that dlls source as a project in your solution. Set the Build Order correctly in Visual Studio and Rebuild Solution will ensure everything gets a clean build.
However, if it's the latter and you will reuse those dlls in other solutions, then they should be in their own solution. Ideally use a Build Server such as Cruise Control or something like it. This will allow you to make changes to the common library and it will recompile it with new version numbers automatically, provided you set it up correctly. Then once your common library has passed its tests and you are happy to release it, put into a "bin" or "Dependencies" folder in the project you are working on. Reference that dll instead of the Project as in the previous example. When you build your project it will use the dll in the bin/Dependencies folder when compiling.
The advantage of this is that if you use a common library in one solution and release it to a client or as a project, then change the common library and release new client solutions/products, you will know exactly which version of the common library is in use. Then you can go to your source control and pull the exact code.
We were using some products and effectively growing them with each client solution we implemented. After a dozen or so projects we had no idea what version of code each client was running. Since we moved to Cruise Control linked with Mercurial for SSC we now clearly know what versions of code all of our products and client solutions are using.

- 3,390
- 14
- 24
-
I found that for each build of each project the Nuget downloads were not getting picked up. So I created a lib folder in each project and copied them in there. This does leave a problem of Nuget updates, not sure how to fix that in the future. Your suggestion about the build order also helped so I give you the tick. – arame3333 Feb 15 '13 at 08:25
I sometimes find I have to delete the dlls and recompile each project before I get an overall clean compile.
Right-click the solution > Clean Solution. And then re-build. This will often times clear up strange build errors.
I also find when i do a build I have to remember to checkout the dlls of each project which are stored in the bin folder, compile each project, check in the dll and then run the build to get a clean compile.
This is most likely the real issue. Do not add the external dll's directly to the bin. Rather, add any 3rd party dll's to a folder at the root of your solution, or really, anywhere else that you can access, but I find the root a good place:
- Solution Folder
- ExtLib (place all your 3rd party assemblies here; use sub-folders if needed)
- Project A
- Project B
- MySolution.sln
Then add a reference to each project as needed from your ExtLib: Add Reference > Browse: add dll's as needed.
Once the dll's are added, make sure they are marked as "copy local": References > Right-Click assembly: Copy Local = True.
If the assemblies you need to reference are in a related project, then just add a project reference; no need to copy local as VS will take care of that for you.
With the above you can keep your 3rd party assemblies in your ExtLib folder and add to source control if needed. Then, whenever anyone pulls down the project from source control, they'll pick up ExtLib folder and any updated assemblies. Whenever you build, the assemblies are referenced from the ExtLib and copied to the bin.
As others have mentioned, do not ever, ever, ever add your bin folder to source control: YMMV.

- 37,266
- 20
- 108
- 140
-
Thank you for that. I need some clarification. When I think about third party dlls, I am thinking about Elmah or EntityFramework as examples. I have put them in a seperate lib and that works fine. But what about the dlls for project A, project B etc? I have put them in the bin directory, but as I mentioned before, I can ONLY do a release build successfully if I check them in. – arame3333 Feb 14 '13 at 09:43
-
I have never used the clean solution option, so +1 for that, it is very useful – arame3333 Feb 14 '13 at 09:45
-
Project A, B, etc... are added as project references. Right click-references > add reference > add project. This assumes the projects are part of the existing solution. Otherwise, treat them as any other 3rd party dll. – Metro Smurf Feb 14 '13 at 14:20