Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paths in Visual Studio post-build event

i have following problem: Because Visual Studio can't handle chain references, i need to copy all "chain reference"-DLLs to my program's bin-folder. For this, i use Robocopy.

The only problem is, that my command-line, i enter in Visual Studio post-build event is split incorrect.

ROBOCOPY "$(TargetDir)" "$(SolutionDir)Map\bin\$(ConfigurationName)\" *.dll /LOG:RCPY.log

This is my build event. All i get now is following:

Gestartet: Fri Jul 06 15:40:30 2012

Quelle : F:\Sicherung\Visual Studio\Projects\Map\Core\Core.GUI\bin\Release\ F:\Sicherung\Visual\
Ziel : F:\Sicherung\Visual Studio\Projects\Map\Core\Core.GUI\bin\Release\Studio\Projects\Map\Map\bin\Release\

Dateien : *.dll

Optionen: /COPY:DAT /R:1000000 /W:30

Whyever, it splits it at the empty space of "Visual Studio" in the second path/parameter. I tried everything with the quotes, but either Robocopy isn't executed (at least the log file doesn´t get overwritten) or the i get this log entry shown thereover...

And Visual Studio shows:

The command ... exited with code 16

which means there is a fatal error, mostly cause of invalid paths.

like image 620
SharpShade Avatar asked Jul 06 '12 13:07

SharpShade


People also ask

How do I find the build path in Visual Studio?

Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.

How do I create a post build event in Visual Studio?

In the Post-build event command line box, specify the syntax of the build event. Add a call statement before all post-build commands that run . bat files. For example, call C:\MyFile.

How do I change the target path in Visual Studio?

In Visual Studio, click Tools > Options. Expand Projects and Solutions and click Locations. The Projects location field defines the default location for storing new projects. You can change this path if you are using a different working folder.

How do I debug a post build event in Visual Studio?

Another way is to check the bin\debug dir for 'PreBuildEvent. bat' or 'PostBuildEvent. bat' which are the file that Visual Studio creates and run during the build events, if there is an error the files remain in the output dir and you can run them manually and spot the error.


1 Answers

Unlike xcopy, robocopy treats \" an escape character, as noted on http://ss64.com/nt/robocopy.html:

If either the source or desination are a "quoted long foldername" do not include a trailing backslash as this will be treated as an escape character, i.e. "C:\some path\" will fail but "C:\some path\" or "C:\some path." or "C:\some path" will work.

Since the trailing backslash is already included in post-build macros, you'll need to add a second backslash or a period to the end of your source and destination arguments:

ROBOCOPY "$(TargetDir)." "$(SolutionDir)Map\bin\$(ConfigurationName)\." *.dll /LOG:RCPY.log

I recommend adding the period, as this eliminates the escape character rather than work around it.

like image 172
BradV Avatar answered Sep 24 '22 21:09

BradV