#1
|
|||
|
|||
Problem with LASTSTEP_OUTPUT and xml output
I'm using Vault 6.1 with the history command in my build script. Vault outputs the results in xml format which is perfect for my needs.
I'm writing a vbscript in Visual Build as the Stepdone event of the vault step, but it doesn't parse the xml correctly. I think I tracked the problem down to visual Build changing the xml text in the LASTSTEP_OUTPUT macro. I use this line to get the text: xmlText = vbld_AllMacros().Item("LASTSTEP_OUTPUT") Instead of lines like this: <item txid="225650" date="5/12/2006 8:57:35 AM" name="_Mainline/file.cpp" type="60" version="411" user="build" omment="Can't use single quote" actionString="Checked In" /> I get a line like this from the macro: <item txid='225650' date='5/12/2006 8:57:35 AM' name='_Mainline/file.cpp' type='60' version='411' user='build' comment=Can't use single quote' actionString='Checked In' /> If you look closely, you will see that the double-quotes of the original output have been converted to single quotes. That by itself is still valid xml and can be loaded. My problem is that the output also contains single quotes which is not valid. the word "Can't" becomes invalid. Is there some option that will let me get the real output of the command that hasn't been converted by Visual Build macro? Thanks, Mike Ballou Last edited by mballou; 05-16-2006 at 01:02 PM. |
#2
|
|||
|
|||
VBP converts double quotes in step output macros to single quotes so that if these macros are referenced in a script expression like "%LASTSTEP_OUTPUT%", double quotes within the value will not cause problems. But this can lead to the situation you're describing if the output actually contains XML attribute values with single quotes. We'll add an option in the next release to disable conversion of double to single quotes in the output macros. For now, you can work around it by converting back to double quotes in the script event before using:
Code:
' convert single quotes surrounding XML attribute values possibly ' containing single quotes back to double quotes output = Application.ExpandMacrosAndScript("%LASTSTEP_OUTPUT%") Set re = New RegExp re.Pattern = "(\s*=\s*)'(([^']|'[^\s])*)'(\s)" re.Global = True output = re.Replace(output, "$1""$2""$4") ' do stuff with output |
#3
|
|||
|
|||
Perfect!
Thank you for the quick response. I look forward to the next version. I tried your work around for converting the single quotes back to double quotes and it also works great. Thanks, Mike Ballou |
#4
|
|||
|
|||
We are also experiencing the same problem. The workaround works great for any comments containing a single quote followed by an s at the end of a word, but we've already had several comments containing single quotes in other parts of the comment field, ex: comment="Comment 'containing' single quotes"
We are building continuously, so if a comment contains a single quote, no changes are found because the xml does not load. Is there a timeframe when a new version will be available? |
#5
|
|||
|
|||
The v6.2 beta (released today) has this capability. More details on the beta are here: http://www.kinook.com/Forum/showthre...?threadid=1973
|
#6
|
|||
|
|||
I installed the beta and it fixed our problem. However, it introduces a new one....
The problem introduced is that in a step done event, I have a Builder.LogMessage statement, but the statement is not finding it's way into the log file. When I uninstall the beta and reinstall 6.1, it's working fine, but I still have the single quote issue. Any ideas? let me know and i can send you the build project if needed. |
#7
|
|||
|
|||
Another change (actually a bug fix) in this build is to not fire the vbld_StepStarted/vbld_StepDone events for a step that is skipped. Is that coming into play here?
|
#8
|
|||
|
|||
Nope, this step is getting executed and the logic w/in the event is being processed, but the Builder.LogMessage output is no longer getting logged
|
#9
|
|||
|
|||
Can you ZIP and post or send a .bld file that demonstrates the problem, and the info from Help | About | Install Info? Thanks.
|
#10
|
|||
|
|||
Attached are the bld files. Basically, the MediLinksCIC.bld fires the ChainMaster.bld. The ChainMaster fires a bunch that do basically the same thing. We can focus in on the MediLinks.bld one to keep it simple. This one is an example of the Builder.LogMessage not getting fired. You probably won't need the first 2 .bld's, but just so you can see our process in its entirety.
|
#11
|
|||
|
|||
I can't find a Builder.LogMessage call in any vbld_StepDone event in the attached files. Please pare things down to a reproducible sample we can build here. Thanks.
|
#12
|
|||
|
|||
So sorry, i should have pointed out that the StepDone calls a Global Function which contains the Builder.LogMessage, which you probably don't get by me sending you the .bld files.
In the Build Solution step of MediLinks.bld, there is a call to CreateReportLink (the global function). It is in this function that the message does not get logged. Below is the global function note that it is also calling a URLEncode function which i've also provided below): Sub CreateReportLink(LinkHeader, ReportDir, FileName) Dim strHTML Dim file Builder.LogMessage LinkHeader strHTML = "<HTML>" strHTML = strHTML & "<BODY>" strHTML = strHTML & "<a href='..\" & URLEncode(ReportDir & FileName) & "'>" & FileName & "</a>" strHTML = strHTML & "</BODY>" strHTML = strHTML & "</HTML>" Builder.LogMessage(strHTML) End Sub Public Function URLEncode(sRawURL) Const sValidChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklm nopqrstuvwxyz:/.?=_-$(){}~&\" If Len(sRawURL) > 0 Then ' Loop through each char For iLoop = 1 To Len(sRawURL) sTmp = Mid(sRawURL, iLoop, 1) If InStr(1, sValidChars, sTmp, vbBinaryCompare) = 0 Then ' If not ValidChar, convert to HEX and prefix with % sTmp = Hex(Asc(sTmp)) If sTmp = "20" Then sTmp = "+" ElseIf Len(sTmp) = 1 Then sTmp = "%0" & sTmp Else sTmp = "%" & sTmp End If End If sRtn = sRtn & sTmp Next URLEncode = sRtn End If End Function |
#13
|
|||
|
|||
LogMessage calls from script event code for a step with logging disabled were incorrectly suppressed. This is fixed in the latest beta download.
|
#14
|
|||
|
|||
Thank you very much. I don't see a new download though, just the same one (6.2). Will this be available soon?
|
#15
|
|||
|
|||
It is, just download it again (it's still the v6.2 beta, only better). VisBuildBld.dll version (Help | About | Install Info) will be 6.1.9.37 after installing.
|
|
|