Sie sind auf Seite 1von 7

IncVer - version update utility

Description:
A utility that will allow you to increase \ update Assembly version data, you can wither use the
executable or the dll (no dependency) the instructions how to use both are below.

Using as the exe with command parameters:


<File Path> = Specific file path; will update the specified file only.
<Folder Path> = Update all matching files in the path (including sub directories).

"0" or "Major" = Update Major version


"1" or "Minor" = Update Minor version.
"2" or "Build" = Update Build version.
"3" or "Revision" = Update revision version.

(You can combine position values to update more than one position, (i.e. command
“Major Revision” will update both the major number and the revision number).

"4" or "File" = Update File Version.


"5" or "Assembly" = Update Assembly version.
"6" or "Both" = Update Assembly and File versions.

“ForceAssembly:<VersionValue>” = Force a specific Assembly File version (this version


number will increase and will be used as the AssemblyVersion).
“ForceFile:<VersionValue>” = Force a specific Assembly File version (this version number will
increase and will be uses it as the AssemblyFileVersion).
“Force:<VersionValue>” or “ForceBoth:<VersionValue>” = Force both Assembly and File
version (this version number will increase and will be used as the AssemblyVersion and
AssemblyFileVersion).

 Command line\s from the VisualStudio Pre-Build event will look like these:
• $(SolutionDir)\IncVer.exe 3 both
Or
• IncVer.exe $(ProjectPath) revision build 6
Or
• IncVer.exe $(ProjectPath) /build /6 /forceAssembly:2.0.1.2

 Command line\s from run dialog will look like these:


• “C:\IncVer.exe” “C:\MyProject\Solution1” minor 5
Or
• “C:\IncVer.exe” “C:\MyProject\Solution1\AssemblyInfo.cs” 0 5
Using as a VS tool:
Click the “Tools” menu and select the “External tool…” menu item.
In the dialog that opens set the path to the exe and add the command parameters
you wish to use
If you wish to make changes every time you run the exe, check the “Prompt for
arguments” check-box in the dialog box,
This will cause the arguments dialog box to appear every time you run the exe,
allowing you to change or view the arguments that are going to be used.

Using the exe with ini file:


(Ini file settings will override command parameter settings).
Place an ini file named as the executable with ini extension (i.e. IncVer.ini) in your path (either
next to the executable or in %WINDIR%).
The ini file should have a [Settings] section; all specified keys will be defined under this section.

RootPath = When it specifies a file, only this file will be updated,


When it specifies a folder; all matching version files in the folder will be updated (see
"IncludeSubDirectories" to include subfolders), if this value is empty; root path of the application
will be used.
ForceAssemblyVersion = Force a specific assembly version assembly version number (See
"UpdateForcedVersion " to update this number after the version files were updated).
ForceAssemblyFileVersion = Force a specific assembly file version assembly version number
(See "UpdateForcedVersion" to update this number after the version files were updated).
UpdateType = Specify what to update;
• "Assembly" or "4" = Assembly version
• "File" or "5" = Assembly file version
• "Both" or "6" = Assembly and file versions.
UpdatePosition = the position to update (you can specify more than one value, delimited with
any value);
1. "Major" or "0" = major version.
2. "Minor" or "1" = major version.
3. "Build" or "2" = major version.
4. "Revision" or "3" = major version.

UpdateForcedVersion = When this value is true and "ForceAssemblyVersion" and or


"ForceAssemblyFileVersion" has a value, the version number this value represents will increase
and will be written back to the ini file.
ShowConfirmation = Show confirmation for each file, allowing you to accept or cancel the
version change.
ShowDoneMessage = Show a message at the end of the version change.
 The ini file should look like this:

[Settings]
UpdateType=Both
UpdatePosition=Magor, revision
RootPath=
ForceAssemblyVersion=10.0.8.9
ForceAssemblyFileVersion=10.0.8.9
UpdateForcedVersion=1
ShowConfirmation=1
ShowDoneMessage=0

Click here to save ini file to your computer

Using the IncVer.dll:

• Copy the dll into the same folder as your project file (not the solution [.sln]).
• Open your <Project>.csproj (or <Project>.vbproj) in notepad.
• Add the following line to the project file, after the <project> tag and before
the first <propertygroup> tag.

// C# or VB //
<UsingTask TaskName="IncVer.IncVerLib"
AssemblyFile="IncVer.dll" />

An example of one of a project would look like this:

// C# or VB//
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="IncVer.IncVerLib"
AssemblyFile="IncVer.dll" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">
Debug</Configuration>

• Scroll on down till you find the <Target Name="BeforeBuild"> tag. It may
be commented out;
• Uncomment it out, and between the open and close tags, add the following:

// C# //
<IncVerLib AssemblyFileLocation =
"$(MSBuildProjectDirectory)\My Project\AssemblyInfo.cs">
</IncVerLib >

// VB //
<IncVerLib AssemblyFileLocation =
"$(MSBuildProjectDirectory)\My Project\AssemblyInfo.vb">
</IncVerLib >

Note! Make sure the path to your assembly file is correct. If it's not in the "My Projects" folder,
make sure you adjust your line above to say where it is. The $(MSBuildProjectDirectory)
variable will be replaced with the folder the .csbproj file is in. So if the assembly.cs file is in
the same location, then do use any subfolder. By default, VS 2005 puts it in the "My Projects"
folder and calls it AssemblyInfo.cs. For VB, it's AssemblyInfo.vb., this dll should work for
both C# and VB projects.

• Save the project file and then open it in VS. Now, every time you build the
project, VS will call the IncVerLib class in the dll and execute the code in it.
The code itself opens your assembly file, edits the version info, and then
saves it, Because you are doing this in the "BeforeBuild" section, it will be
done before you build.

Note: Some project files may not have the <Target Name="BeforeBuild">
tags. If this is the case, I usually just add them after the

// C# //
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> line
for C#.

// VB //
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
line for VB.

I.e.:

// C# //
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="BeforeBuild">
<IncVerLib
AssemblyFileLocation="$(MSBuildProjectDirectory)\AssemblyInfo.cs">
</IncVerLib>
</Target>
<Target Name="AfterBuild">
</Target>
</Project>

// VB //
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<Target Name="BeforeBuild">
<IncVerLib
AssemblyFileLocation="$(MSBuildProjectDirectory)\AssemblyInfo.vb">
</IncVerLib>
</Target>
<Target Name="AfterBuild">
</Target>
</Project>

Points of Interest:

• Sometimes (only when using as DLL), the revision number will jump 2 or 3
numbers. No idea why, maybe something is not re-loading correctly or that
the compiler is calling the DLL twice or more.
• If you have the project properties window, or the assembly file\s open, the
version may not increment.

Das könnte Ihnen auch gefallen