Shared Files in Output Directories in C # Program

My VS2008 solution has the following setup.

  • Program1
  • Program2
  • Common.dll (used and mentioned 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 when compiling Program1, it will give an error that it will not be able to copy Common.dll if Program2 is running. And vice versa.

The annoyance here is that I don’t even make changes to Common.dll often, but in 100% of cases it will try to copy it, and not only if there are changes. In the end, I have to close all the programs, and then create and run them.

So my question is: how do I only copy VS2008 Common.dll, if there are changes in the Common.dll project?

+3
source share
5 answers

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 (same as program1 and program2
  • in project program1 and program2: set "copy local" to false in the link to common.dll

Thus, Visual Studio tries to copy the common.dll file if its source code has changed.

+1
source

Common.dll Program1, Program2 DLL? , ? , Program1/2 Common.dll?

+1

, , :

System.Reflection.Assembly.GetExecutingAssembly().Location
+1

- Common.DLL

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

.

, DLL, . :)

0

, ( ), "bin" , "bin\Debug", "\bin\debug" ( - ).

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

Let the visual studio take care of the update file, etc.

NOTE If you are in the middle of using application debugging, you still cannot copy the new file, it is locked, etc.

PK :-)

0
source

Source: https://habr.com/ru/post/1731054/


All Articles