PDA

View Full Version : Write XML: Xpath not found but I don't want the step to fail


deramor
10-04-2011, 01:44 PM
Hello-

I am using the Write XML project step to remove Source Safe information from Visual Studio project files. I basically find the XML fields and NULL them.

This works fine when the project file I am looking at has source control information in it. When this information is not present, the XML fields are not there for me to NULL. This causes the step to fail since the XPath I used was not found. The step failure is not important to me for this reason but for other reasons it would be. Is there any way to have this step continue when the XPath is not found but fail in all other cases?

Simply marking the step to continue and not execute failure steps is not a good alternative.

I have in the past edited a single step's script to pass a step for a particular exit code:

Sub vbld_StepDone()
If CLng(Application.ExpandMacros("%RUNPROGRAM_EXITCODE%")) = -1073741819 Then
Step.BuildStatus = vbldStepStatSucceeded
End If
End Sub

However I see no macro that is created with an exit code for me to work with in this instance. The above edit was to work around a problem with InstallShield which apparently uses the run program project step underneath which in turn generates the %RUNPROGRAM_EXITCODE% macro as part of its execution. I do see the LASTSTEP_STATUS but it seems to be only a pass/fail value rather than an exit code.

Thanks-
Rob

kinook
10-04-2011, 06:37 PM
The Write XML action does not run a program, so there is no exit code. You could use the READ_XML system macro to conditionally build the step only if the XPath expression is found in the file.
http://www.kinook.com/VisBuildPro/Manual/systemmacros.htm
http://www.kinook.com/VisBuildPro/Manual/buildrules.htm

deramor
10-05-2011, 10:57 AM
Ah that makes sense. Thanks for pointing out the obvious workaround.