PDA

View Full Version : Command line usage


wallywojo
01-05-2006, 02:47 PM
Can someone supply a working sample where multiple macros are defined from the command line. I have not been able to get this working.

kevina
01-05-2006, 03:27 PM
invoke the provided .bld file from this command line:

visbuildpro "TEMPMACRO1=T1" "TEMPMACRO2=T2" "TEMPMACRO3=T3" /d /b "c:\path\to\multiplemacros.bld"

See the following for more details:
http://www.visualbuild.com/Manual/?command_linegui.htm
http://www.visualbuild.com/Manual/?consoleapp.htm

You can also have VBP generate the command-line for you by adding some temporary macros and then choosing Tools | Create Scheduled Task on the menu, then copying the command from the task and deleting the task:
http://www.visualbuild.com/Manual/?scheduleautomatic.htm

wallywojo
01-05-2006, 04:12 PM
Thank You.

It ended up that the problem was Word formatting of the quotes. Thanks for reinforcing that the parameters were as expected.

Wally

mseminatore
01-17-2006, 08:14 PM
What if I want to have Project macros that are overridden by the command line? Is that possible? Using temporaries means that I can't run using the GUI without defining the temporaries.

Do the values passed on the command line equate to temporary macros? If so do folks just tend to create some steps to check for the temporaries and initialize them to defaults if not found?

kinook
01-18-2006, 08:10 AM
VBP implements an order of precedence (temporary, project, global, system [highest to lowest]) when macros are referenced like %MACRO_NAME% within step fields (or like Application.ExpandMacrosAndScript("%MACRO_NAME%") within script code), and overriding a project macro (which defines the default) with a temporary macro (on the command-line) is an ideal use of this feature. See the following help topics/samples for more details:

http://www.visualbuild.com/Manual/?macrostab.htm
http://www.visualbuild.com/Manual/?hints.htm (3rd from last bullet)
http://www.visualbuild.com/Manual/?visbuildprosample.htm

mseminatore
01-18-2006, 11:54 AM
Right I realized I meant to ask a related question. Is it possible to use environment variables to the same effect? IOW rather than having to customize the command line can I simply set some environment variables (say from within a batch file) and have those override Project macros which define the default.

My recollection is that env vars are considered to be System macros and are thus lower priority than System macros.

mseminatore
01-18-2006, 01:05 PM
Alternatively if the temp macros could be read from a text file that would be handy. I have something like 20 macros I would like to define in order to parameterize my builds. Specifying them all on command line is a little cumbersome.

kinook
01-18-2006, 05:04 PM
Regarding environment variables, you could add a Run Script step at the beginning of the project to iterate over all environment variables, storing them in temporary macros. Although you probably don't want to do this for all variables, so you'd need to filter the list in some way. In VBScript, something like this:

Set shell = CreateObject("WScript.Shell")
Set env = shell.Environment("PROCESS")
For Each var In env
' logic here to parse the name/value out and
' determine if this variable should be processed
vbld_TempMacros.Add name, val
Next

Regarding reading from a file, you could again use a Run Script step to iterate over the file contents and assign the values to temporary macros. Something like the attached sample.

deramor
04-24-2014, 05:39 PM
VBP implements an order of precedence (temporary, project, global, system [highest to lowest]) when macros are referenced like %MACRO_NAME% within step fields (or like Application.ExpandMacrosAndScript("%MACRO_NAME%") within script code), and overriding a project macro (which defines the default) with a temporary macro (on the command-line) is an ideal use of this feature. See the following help topics/samples for more details:

http://www.visualbuild.com/Manual/?macrostab.htm
http://www.visualbuild.com/Manual/?hints.htm (3rd from last bullet)
http://www.visualbuild.com/Manual/?visbuildprosample.htm

I realize this is an old topic but I couldn't find an answer to my question and this thread was the closest I could get. I attempted to pass a value on the command line to change the value of a project macro. However this method caused a temporary macro to be created instead. From reading the thread and the links this is expected. Is there any way other than some workaround (registry/external file) to define a project macro on the command line?

kinook
04-24-2014, 05:51 PM
Only temporary macros can be created on the command-line. You could add a Run Script step to create/update a project macro for each temporary macro. See the attached sample.

But normally you would not want to modify a project within a build, because Visual Build will prompt for changes on exit.
http://www.kinook.com/Forum/showthread.php?t=245