Artiom
Artiom

Reputation: 7847

Copy resource files to executed assembly

May be it's silly, in this case please tell me better way to manage that.

I have a Console application (ConsoleProject). It references to my Class library (Library1) and Library1 references to another my Class library (Library2)

ConsoleProject => Library1=>Library2

Library2 has some text resource files to parse.(Build action = Content, Copy to Output Directory = Always)


Is it possible, these files to be coppied to the executed path of ConsoleProject?

for now I have to add another reference ConsoleProject=>Library2 just for these files. I would like to avoid this.

Upvotes: 0

Views: 967

Answers (2)

tsells
tsells

Reputation: 2771

If possible I would make those files and embedded resource in your Library2.dll and then stream them to a temp location when needed for the use in your console program. This is the cleanest way of doing it and is less prone to build / file copy issues later.

Here is a post I did surrounding managing file dependencies with unit / integration testing which provides some examples on how to manage the files appropriately.

http://tsells.wordpress.com/2012/03/06/how-to-run-integration-tests-with-file-dependencies/

Upvotes: 1

Vinoth
Vinoth

Reputation: 2439

  1. Make those files as embedded resource.
  2. Right click on those files and Set the CopyToOutputDirectory to Copy always

UPDATE: Post Build Commands:

if not exist c:\somedir\bin md c:\somedir\bin
xcopy /y c:\yourcodedir\bin\abc.txt c:\somedir\bin

Upvotes: 1

Related Questions