0

I have a C# Project with the following line in the Pre-Build events:

copy "(RSSDK_DIR)\bin\win32\libpxccpp2c.dll" "($OutDir)" /Y

RSSDK_DIR is an environment variable and $OutDir is a recognized macro symbol. I am trying to copy the given DLL from the first directory to the output directory.

When I build the project I get the error:

Error   1   The command "copy "(RSSDK_DIR)\bin\win32\libpxccpp2c.dll" "($OutDir)" /Y" exited with code 1.   

I have done a similar task in C++ projects and it worked fine. In addition, you could see the actual command fully expanded being run when the build event fires in the Output window. In this case with my C# project, it doesn't appear to be expanding either the environment variable or the macro symbol. I've read other SO posts on doing a file copy like this and my version appears to be the same as what I've seen.

How can I get this to work and are there any IDE settings or tools to help debug this?

Robert Oschler
  • 14,153
  • 18
  • 94
  • 227
  • Does my updated answer works for you??? – Juan M. Elosegui Aug 15 '15 at 18:20
  • @jmelosegui No it doesn't and I don't have time to put any more effort into this right now. I did upvote your answer since I found it useful, but since I still have the problem I didn't mark it as the accepted answer. – Robert Oschler Aug 16 '15 at 14:29

1 Answers1

1

Try this, for specific macro variables the correct syntax is $(OutDir) instead of ($OutDir)

For environment variables you have to use the %variable% syntax, but because % is a reserved character in MSBuild you will need to replace it with %25.

That does not work for me either, but good news is you could use the same syntax for environment variables though.

So you command should work like this

copy "$(RSSDK_DIR)\bin\win32\libpxccpp2c.dll" "$(OutDir)" /Y

Notice that inside visual studio $(OutDir) is a virtual path and depending on what you are trying to do, you should consider using $(TargetDir) instead.

Juan M. Elosegui
  • 6,471
  • 5
  • 35
  • 48