|
|
Thread Tools | Rating: | Display Modes |
|
#1
|
|||
|
|||
csproj file containing "&" in a PreBuildEvent step fails to parse
In a csproj file I have a line like this:
PreBuildEvent = 'cd $(ProjectDir) & "$(DevEnvDir)\..\..\Vc7\Bin\nmake"' When I try to build the solution containing this csproj file under Visual Build Pro I get this error: Error loading info for project file 'C:\Foo.csproj': An error occurred while parsing EntityName. Line 19, position 52. The character at position 52 is the "&". Is there a way to change the PreBuildEvent command so both Visual Studio and Visual Build accept it? |
#2
|
|||
|
|||
VBP's Make VS.NET action uses the .NET XML parser to process VS.NET project files, so it requires the files to be valid XML. Oddly, VS.NET 2002/2003 doesn't create a valid XML file when there is an ampersand char in a build event, and it also doesn't parse a correctly encoded ampersand char if the file is converted to valid XML.
The simplest workaround is to put your build event commands on multiple lines instead of using &. If you click the ... button beside the event command line field, you can enter commands on multiple lines using Enter. VS.NET does appear to encode the cr/lf chars properly. |
#3
|
|||
|
|||
I'm not sure VS does encode multiple lines correctly:
PreBuildEvent = 'cd $(ProjectDir) {amp pound xd; amp pound xa;}* "$(DevEnvDir)\..\..\Vc7\Bin\nmake"' is what I get when I specifiy the commands on multiple lines in the VS GUI. I tried replacing the original "&" using the VBPro command "replace in file" right before I build the VS solution. However, it looks like VBPro doesn't use the modified file as the step to build the solution fails. (*the actual characters wouldn't show up in this message so I had to use the full words. Sorry if this is confusing) Last edited by joes; 11-19-2004 at 01:58 PM. |
#4
|
|||
|
|||
Using VS.NET 2003, putting the commands on multiple lines in the build event, I was able to build in VS.NET or VBP. The newline was written as

 which is valid XML. |
#5
|
|||
|
|||
That is exactly what gets put in my file when I break the command up into two lines. VBPro in my environment doesn't like it for some reason. I must be doing something wrong.
I've tried moving the commands to a bat file and calling it from VS and VBPro and that works. I think I'll just go with that solution. |
#6
|
|||
|
|||
I tried again and I did get the "split line command" to work. I've been hacking the bld file together and I guess some stale state was building up. I created a fresh build step and it works now.
Thanks for the help. |
Thread Tools | |
Display Modes | Rate This Thread |
|
|