Link to home
Start Free TrialLog in
Avatar of FrancineTaylor
FrancineTaylor

asked on

Resource files not being copied to /bin when compiled thru VS

My company has a product with a large number of standalone modules (AP, AR, etc).  It is written in C# and VB.NET, developed with VS, currently compiled in 2010.

One of my areas of responsibility is the icons, mostly contained in .resource files.  There are about a dozen .resource files, most needing to be copied into all the modules' /bin directories.

Here's the behavior that we are experiencing.  Say I modify a .resource file.  I check it into Subversion and it goes into the pipeline to be distributed to QA and UX through the normal build.  No problems there.

But when other developers try to compile, they end up getting the old version of the .resource file copied into their /bin directories.  If a new .resource file was added, they don't get it at all.  If they copy it manually, it is blown away and overwritten each time they compile.  So we have to use batch files to do a manual copy, run after the application is started up but before we enter our login.

What mechanism does the copy of those .resource files during compilation, and how can I access it?  I'm guessing it must be something individual to each project, because there are some modules that copy everything correctly, some which copy incorrectly only if you manually delete the contents of /bin, and some which delete and copy incorrectly every time.

Can someone point me to the script or project area that controls this process?
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FrancineTaylor
FrancineTaylor

ASKER

The reason we are doing our icons with .resource files is that we have hundreds of icons and dozens of projects and embedding every icon in every project is just not practical.  This way, an icon change only requires that we edit a single file instead of dozens.

The post build event sounds like the best candidate for what I want.  I've discovered that there's some kind of complicated deployment scripting that does the job for the compiled/installed systems, which is why things work for them.  The resource files aren't even included anywhere in the projects that I can find.  I have no idea what mechanism is copying them in the first place but they expect me to fix the process.

I'd like to build a batch file in the highest directory that takes in the resource files and all the modules.  The name of it is ClientSide.  The batch file would copy all .resources files from the directory where they are stored, into the bin directory of the project being compiled.

So, the batch file would say:

copy /ResourceRepository/*.resources  <bin of current project>

Then I would want to put something in the project's Post Build Event Command Line to say execute this file, which would reside two directories lower, and would need to take the project name or directory path as a parameter.

How would I tell the batch file to take a parameter?  Just "%1"?  And then how would I get the path and send it as a parameter?  Remembering that it is not just the current directory that I need, but the one below it as well?

So, as an example, if my top level directory was /ClientSide, and my project was /ClientSide/AR/AR_Host, I would need to send "/AR/AR_Host" to the batch file.
Search the documentation for "Pre-build Event/Post-build Event Command Line Dialog Box". You will get a list of the macro commands that you can use inside those scripts. The one for the bin is $(TargetDir). There are many others to get the project directory, the solution directory, paths relative to a few others, etc.

I suggest that you also give a look to the references in the See Also of that documention page. You will get a few sample scripts that could be useful.
I've looked through that documentation and all the examples I could find, but I am still unable to find the key element to this task.  How would I call a batch file which is one directory below $(SolutionDir)?

I've tried:    call  ..\$(SolutionDir)frantest.bat

...but got this error:

The command "call ..\c:\ClientSide\VP\frantest.bat" exited with code 1

I can see how it misinterpreted what I asked for, but I don't know how to fix it...
I understand your need better with the last post.

As I see them, the build event scripts use Visual Studio standards. In Visual Studio, the project directory is seen as a root and everything is under that directory. So they do not react to some other standards such as the ..\ to move up one directory.

However, the script can call an executable file and pass command lines parameters to it. You have an example of such an .exe in the "How to: Specify Build Events (Visual Basic)" topic of the documentation.

An application will react to the ..\. Store it on a network drive that is seen by all the programmers and call it from you script, passing $(SolutionDir) as a parameter. The application will do the job.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks again for spending so much time helping me!