Post-build event with folders which contains spaces

If you want to use a Post-build event with folders which contains a space often you get an error like: The system cannot find the file specified. c:\WINDOWS\...

If you want to use a Post-build event with folders which contains a space often you get an error like:

The system cannot find the file specified.

c:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(3397,13):
error MSB3073: The command
"COPY C:\Projekte\_Learning By Doing\EsriDE.QA.StyleCop\bin\Debug\EsriDE.QA.StyleCop.dll
"C:\Program Files\Microsoft StyleCop 4.3""
exited with code 1.

In my case i used the macro $(TargetPath) in following line which contains indirectly the spaces in “_Learning By Doing”:

COPY $(TargetPath) "C:\Program Files\Microsoft StyleCop 4.3"

To avoid this error also the makro must putted in quotes.

So the correct line is:

COPY "$(TargetPath)" "C:\Program Files\Microsoft StyleCop 4.3"