PDA

View Full Version : C# Pre-Build step corrupted by Visual Build


DHearn
11-17-2003, 10:15 AM
If a C# project (using VS.NET 2003) has a pre-build step defined which contains quotes (e.g. dir "c:\windows") and you have 'Set the base address to a random value if not set' selected in the Visual Build Step Properties on the Versions page, then Visual Build replaces the quotes in the project file with ';quote' (converts to valid xml).

Since the pre-build step is executed as a batch file, you get an invalid syntax.

To get around the problem, I changed the Visual Build setting to 'No' since I don't think the option is doing anything for a C# project anyway. But it could pose a problem if my solution also contained C++ projects.

kinook
12-05-2003, 01:37 PM
That is due to a bug in the VS.NET C# project file parser in that it doesn't properly parse a double quote char in the project file represented as " (the Make VS.NET action uses the .NET XMLDocument class to modify the base address in the project file, which also results in literal double quote chars in the file getting converted to " when saved).

Not using the base address option is the required workaround for C# and VB.NET projects. VC++.NET correctly writes (and parses) quote chars within project settings to the .vcproj file as " so it won't be a problem for C++ projects. You would need to put the C++ projects in a separate solution or create a C++-only solution and corresponding 'no build' Make VS.NET step to use the base address option.

wellilein
12-01-2005, 02:54 AM
Independent from the base address setting I get a mistake during the execution of the post build event.

In my case it seems to have problems with newline characters, too. So it says:
Command "quot" is wrong or can't be found.
Command "#xD" is wrong or can't be found.
Command "#xA" is wrong or can't be found.

Is there a workaround for this?

kinook
12-01-2005, 07:39 AM
The Make VS.NET Action may also modify the project file if the 'Update the output directory' option on the Project/Solution tab is checked. A workaround might be to uncheck that as well (although I've never seen the error you report caused by VBP).

wellilein
12-01-2005, 08:20 AM
Hmm, yes I have set the "Update output directory" flag... but I think I need that one.

Actually I don't want the post build steps to be performed.
I just need them while working with VS.NET. When using VBP, the build script will perform the necessary steps.

Perpaps you can introduce another checkbox like
[ ] Skip post build event
in one of the future versions.

Maybe the messages I posted are not correct. I just translated them from the german version o VBP.

kinook
12-01-2005, 09:08 AM
Attached is a project that fixes up the .csproj files after modification by VBP so that VS.NET loads build events properly.