Visual Studio 2003 Post Build event multi-line format issues

M

michael.lang

I am using PostBuild events in a C# project to run some tasks, but only
when in release configuration mode. The build events run perfectly as
expected when run. The problem comes when I save the project, close
VS, and reopen VS and the project.

When I build again, i get a post-build event error. So I open the
event to look at it. Guess what, it is not the post-build event i
saved. Instead all the carriage returns are replaced with 
.
and line feeds with 
. This is proper formatting for saving to
xml format from what I can tell. However, visual studio should parse
that format into the orginal format when the project opens.

What can I do? Is it too late to get a service pack for VS2003 now
that Visual Studio 2005 is out?

here is a partial of my orginal post-build event. I left out a bunch
of calls to xcopy release files around.


IF NOT $(ConfigurationName) == Release GOTO end

call "C:\Program Files\XHEO\CodeVeil\v1.0\cve.exe" /project
$(ProjectDir)$(TargetName).cvp

:end
echo Finished Post Build Event

I use the same post-build event text for all my projects in the
solution. That's why I use variables. I have a separate "cvp" file
for each project.

I tried hardcoding paths and putting them in an external batch file
that I called in the post-build event. But to call that just in
release mode I still needed the IF statement, and thus multiple lines.
This still has the same formatting issue.

Anyone have a workaround? Anyone know if this is fixed in VS2005?

Michael Lang
 
M

michael.lang

Well, I found a workaround. I would still rather the VS2003 team
released a patch for this. The workaround adds more file maintenance
to the devlopment cycle.

1) create a separate batch file for each configuration. The
configuration name must be a part of the file name. Example:
PostBuildRelease.bat and PostBuildDebug.bat.

You need to have a file for each configuration, even if you don't want
to do anything for that configuration. Otherwise you'll get build
errors.

2) Set the post-build event text to build the name of the bat file and
call it. Example:
call $(ProjectDir)PostBuild$(ConfigurationName).bat

That's it. But now I have a more busy batch file to maintain. My
Debug btach file just echo's that it is complete. But the release one
is more like this...

call "C:\Program Files\XHEO\CodeVeil\v1.0\cve.exe" /project
C:\ProjectRoot\MySolution\MyProject\ProjectName.cvp
echo Post Build Event Complete

I also can't reuse the same text for the build events of all the
projects. If the project is deployed to a different working folder on
another developers machine, the build event won't work for them. Each
developer would have to maintain their own batch files, or the team has
to enforce the same working folder location. Neither is a good option.

I hope there is a better workaround!

Michael Lang
 
R

Ravi Ambros Wallau

I also use multiline post-build events in my solution, but I never had this
kind of problem. It works perfectly for me.
We have a lot of projects that uses exactly the same post-build script.
What I do is to create an environment variable that holds some Visual Studio
environment information (set CONFIGURATION=$(Configuration), and, if
necessary, you can place two commands in the same line using the && command.

set CONFIGURATION=$(Configuration) && ($ProjectDir)\PostBuild.cmd

or

set CONFIGURATION=$(Configuration) && set WHATEVER=($Whatever) &&
($ProjectDir)\PostBuild.cmd

and so on...
 
H

Huihong

Michael,

This might be unrelated to your question, but since you are using
protection tools for your .NET applications, you may want to take a
look of my DeProtector sample with full source code before shipping
ypur products. It explains the mechanims howl whole assembly encryption
is failed to protect intellectual properties. Theis simple DeProtector
defeats all current protection tools on the market, whether it's
anti-debug or not.

http://www.remotesoft.com/deprotector

Huihong
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top