2024年4月5日发(作者:)

-p--pin

-r--revision

-i--inputfile

-o--outputfile

-v--version

“BuildDay” calculates the build

number based on [lastdigitofyear]

[dayofyear].

A version number inSpecifies the version number

Version should output.

The pin option allows you to pin

the version number.

"Fixed" | "Automatic" |Specifies the algorithm

"Increment" |UpdateVersion should use to

calculate the revision number.

"Automatic" calculates the

revision number based on

[secsincemidnight/10].

"Increment" calculates the

revision number by incrementing

the current revision number by

one. "Fixed" causes the revision

number to remain the same.

Path to an existingThe file UpdateVersion should

as the input. If the inputfile

option is not present

UpdateVersion will use the

standard input stream as its input.

A valid file UpdateVersion should

write its output to. If the outputfile

option is not present

UpdateVersion will write its output

to the standard output stream.

"Assembly" | "File"Specifies the version number to

update. The default is "Assembly"

which is backward compatible

with previous versions of

UpdateVersion. Use "–v

Assembly" to update the

AssemblyVersion attribute. Use

"–v File" to update the

AssemblyFileVersion attribute.

Return Values

0 UpdateVersion successfully read the input and wrote the output. Note: UpdateVersion returns 0 even when it does not find an

AssemblyVersion attribute string to update in the input. If that happens UpdateVersion writes a warning to the standard error stream.

1 UpdateVersion was unable to parse the command line options. See the standard error stream for more information. Note:

UpdateVersion does not write to the output when this happens.

2 UpdateVersion was unable to read the input. See the standard error stream for more information. Note: UpdateVersion does

not write to the output when this happens.

3 An error occurred while UpdateVersion was searching for the AssemblyVersion attribute or while it was calculating the new

version number. See the standard error stream for more information. Note: UpdateVersion does not write to the output when this happens.

4 UpdateVersion was unable to write the output. See the standard error stream for more information. Note: UpdateVersion does

not write to the output when this happens.

Usage Examples

Command Line or Batch File

Standard input and standard output:

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion AssemblyVersion("1.0.0.8298")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b Increment AssemblyVersion("1.0.1.8310")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b Increment -r Increment

AssemblyVersion("1.0.1.1")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b MonthDay -s 2002-11-23

AssemblyVersion("1.0.23.8335")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b MonthDay -s 2000-11-23

AssemblyVersion("1.0.2423.8339")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b MonthDay -s 11/23/2000

AssemblyVersion("1.0.2423.8339")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -p 1.2.3.4 AssemblyVersion("1.2.3.4")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b BuildDay AssemblyVersion("1.0.3298.7453")

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b Increment -r Fixed

AssemblyVersion("1.0.1.0")

C:>echo AssemblyFileVersion("1.0.0.0") | UpdateVersion -v File

AssemblyFileVersion("1.0.0.7517")

Redirecting to and from standard input and standard output

C:>UpdateVersion -b Increment < >

Specify the input and output files on the command line

C:>UpdateVersion -b Increment -i -o

You can mix and match all of these techniques so you could easily specify an input file on the command line and write the output to

standard output like so:

C:>UpdateVersion -b Increment -i

To specify the output file on the command line and read the input from standard input do this:

C:>echo AssemblyVersion("1.0.0.0") | UpdateVersion -b Increment –o

Use UpdateVersion with Visual Studio .NET

You can add UpdateVersion to the Tools menu as an External Tool. You can then select the UpdateVersion command from the menu to

update your or file. Just select Tools -> -> Add and enter values similar to the following:

Title: Update Version Number

Command:

Arguments: -b MonthDay -s 2002-11-23 -i "" -o ""

Initial directory: $(ProjectDir)

Use Output window: Checked

If UpdateVersion is not in your PATH you will need to provide the full path where UpdateVersion can be found. You can specify any valid

options for the Arguments.

Use UpdateVersion in a Makefile

Create a new Makefile with the following contents:

test:

UpdateVersion -b MonthDay -s 2002-01-21 -i -o

Then run nmake.

Use UpdateVersion with NAnt

Create a new NAnt script named with the following contents:

" verbose="true" failonerror="true" />

Then run .

Because UpdateVersion returns a non-zero value when it fails your NAnt script will fail as long as the exec tasks' failonerror option is true.