0

I've got a .NET solution which relies upon a third party API. The API appears to mostly be an interface which depends on other files (sqlite, dlls, license, etc.). The third party classes are used throughout a number of my projects, and seemingly have to sit in the same location as my final executable.

The third party directory looks roughly like this:

RootDirectory
     File1.dll
     File2.dll
     Subdirectory
          FileA
          Subsubdirectory
               FileB
               FileC
               etc.

On build, the application has to look like this, or else the API doesn't work:

MyApp.exe
ThirdPartyAPI.dll
File1.dll
File2.dll
Subdirectory
     FileA
     Subsubdirectory
          FileB
          FileC
          etc.

I'd like to keep the dependent file structure intact in a location called [SolutionDir]\RootDirectory, and have them simply copy over to my build as needed. The problem I seem to be having is I can't copy files from RootDirectory when I compile. If I try to delete my bin, it says that File1 and File2 are in use, so I'm assuming that's the hold up.

I tried using this post build event: xcopy "$(SolutionDir)RootDirectory\" "$(TargetDir)" /s /e /h It works sometimes, fails with a Code 2 other times...and haven't figured out why yet.

Any thoughts or other ideas?

Switch386
  • 454
  • 6
  • 19
  • Have you read http://stackoverflow.com/questions/7835304/why-would-a-post-build-step-xcopy-occassionally-exit-with-code-2-in-a-teamcity ? – Eugene Podskal Jan 28 '17 at 19:22
  • Yeah, I've read and tried that and a couple other options. It doesn't seem to help. I'll also mention I'm not dead-set on using xcopy/build events. It's just what seemed to make sense. – Switch386 Jan 28 '17 at 19:29

1 Answers1

2

In visual studio, you can link a solution file to a project.
Just add your 3rd party files as solution files then while holding the ALT key drag them to the project that builds your final executable and drop them.
If done correctly, those files will have a small blue icon.
And finally, change their "Copy to Output Directory" property to "Copy if newer".

When you build your project, those files will then be copied to the output directory.

Seb
  • 620
  • 1
  • 5
  • 11
  • I'll give it a shot, but if I'm remembering correctly, you can only do one file at a time. This would work aside the company puts out updates almost weekly, and the files to include are not consistent. All I know is the directory name, the subdirectories and files can change with every release. – Switch386 Jan 28 '17 at 20:20
  • In that case, the xcopy would still be the best solution then. But may I suggest you have a look at this topic ? http://stackoverflow.com/questions/7835304/why-would-a-post-build-step-xcopy-occassionally-exit-with-code-2-in-a-teamcity – Seb Jan 28 '17 at 20:28