views:

216

answers:

5

My VS2008 solution has the following setup.

  • Program1
  • Program2
  • Common.dll (used and referenced by both Program1 and Program2)

In debug mode I like to set my output directory to Program Files\Productname, because some code will get the exe path for various reasons.

My problem is that Program1 when compiled, will give an error that it could not copy Common.dll if Program2 is started. And vise versa.

The annoyance here is that I don't even make changes to Common.dll that often, but 100% of the time it will try to copy it, not only when there are changes. I end up having to close all programs, and then build and then start them.

So my question is, how can I only have VS2008 copy the Common.dll if there are changes inside the Common.dll project?

+1  A: 

Why not just reference Common.dll in both Program1 and Program2 instead of copying the DLL? That way the latest version is always available and always compiled with the application? In addition, you could debug from Program1/2 into Common.dll?

Nissan Fan
I don't say to copy the DLL, it just happens automatically via the reference.
Net Citizen
+1  A: 

Instead of changing your output directory so you know your executable's location, why not use:

System.Reflection.Assembly.GetExecutingAssembly().Location
Andy West
This will also solve the problem when someone doesn't install to the blessed path, uses a localized version of Windows, an x64 edition, etc.
Mark Brackett
A: 

Put something like this in your Common.DLL Project

copy $(TargetPath) $($ProjectPath)..\..\Program1\
copy $(TargetPath) $($ProjectPath)..\..\Program2\

And reference them from their respective locations.

Ideally you should put all three projects into one solution and reference the projects not the dll's, build the whole solution and then run it. This takes care of all this automaticly :)

the_ajp
Visual studio does this automatically. The problem is running the applications once deployed, not in the debugger.
Billy ONeal
+1  A: 

I tried the following and I think it shows the behavior you are looking for:

  • change the output of the common.dll project to Program Files\Productname (i.e. the same as program1 and program2
  • in program1 and program2 project: set the "copy local" to false on the reference to common.dll

This way Visual Studio only tries to copy the common.dll if its source code changed.

Stefan Egli
A: 

All I do (for debug reasons too) is create a "bin" folder at the solution level and change the Output path on the Build tab of project options on all the projects to a common path, i.e. "bin\Debug\" to "solution\bin\debug" (where solution is the solution path).

Do this for each "configuration", e.g. "solution\bin\release" etc

Let visual studio take care of the updates file etc.

NOTE If you are in the middle of using the debugging the application you won't be able to copy the new file in anyway, it's locked etc...

PK :-)

Paul Kohler
this does not answer the question at all. The point is that there are multiple exe components to the application that all reference the dll.
Net Citizen