Howdy all,
I'm using VS 2005 (.NET 2.0). I have a windows forms application that consists of two projects. One project is the application itself, and the other project is the "setup" project. I want to have the setup project copy the msi file to a "ForDistribution" directory via a Post-build event. The post-build event was added to the setup project as follows:
1.) Click on the setup project in the solution explorer.
2.) In the Properties window, select PostBuildEvent.
3.) Click on the ellipses (...) to open up the "Post-build Event Command Line" editor.
4.) Enter the following lines into the editor:
IF NOT EXIST "$(ProjectDir)..\ForDistribution\WindowsInstall" mkdir "$(ProjectDir)..\ForDistribution\WindowsInstall"
copy "$(BuiltOuputPath)" "$(ProjectDir)..\ForDistribution\WindowsInstall"
IF ERRORLEVEL 1 EXIT(1)
5.) Click "OK"
6.) Rebuild the solution
The post-build event has 3 lines of text (which may not show up correctly in this forum). The first line is "IF NOT EXIST", the second line begins with "copy", and the third line begins with "IF ERRORLEVEL".
Here's the problem: When I build the solution right after adding the post-build event to the setup project, everything works fine. Later (usually after closing the solution and re-opening it the next day), my build fails. It turns out that the 3 lines I had entered were compressed into one line, removing the carriage returns. When the batch file is executed for the post-build event, it appends the "copy" of the second line to the directory it creates in the first line.
So, the problem here is that the post-build event is losing its carriage returns, thereby causing the event to fail when it's processed. Does anybody know how to correct this Is this a bug in VS 2005
Thanks,
Dan

Post-build event stripping carriage returns
DDH
thanks
patrick
VCProgrammer
Hi -- unfortunately, this is a known issue with VS 2005 and Setup/Deployment projects. We are looking to get this fixed as soon as possible...
You might be able to work around this by putting all commands on one line and separating them with AND (&&). For example:
(if not exist "$(ProjectDir)..." mkdir "...") && copy "$(BuiltOutputPath)"
Let me know if this works for you.
Thanks,
-- Izzy
Izzy Gryko
Lead Software Design Engineer
Microsoft Visual Studio Core Development
izzyg@microsoft.com
Brett Blatchley
Faced with the same scenario, this worked for me.
Regards,
David
Clemens Vasters - MSFT
It might be that you already have some .exe files inside the $(ProjectDir)..\ForDistribution\WindowsInstall directory, which are write-protected, because they are under source control! checkout these files, run the build again and it works!
Bruce Rosner
I had the same issue and the solution worked out for me. Hope the bug is fixed with the release of VS 2008.
Thanks
Sanjeev