Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] Third Party Tools (https://www.kinook.com/Forum/forumdisplay.php?f=3)
-   -   csproj file containing "&" in a PreBuildEvent step fails to parse (https://www.kinook.com/Forum/showthread.php?t=627)

joes 11-19-2004 12:55 PM

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?

kinook 11-19-2004 01:34 PM

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.

joes 11-19-2004 01:53 PM

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)

kinook 11-19-2004 02:25 PM

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.

joes 11-19-2004 04:14 PM

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.

joes 11-19-2004 06:31 PM

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.


All times are GMT -5. The time now is 05:48 PM.


Copyright © 1999-2023 Kinook Software, Inc.