Beruflich Dokumente
Kultur Dokumente
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.
(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).
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
[Settings]
UpdateType=Both
UpdatePosition=Magor, revision
RootPath=
ForceAssemblyVersion=10.0.8.9
ForceAssemblyFileVersion=10.0.8.9
UpdateForcedVersion=1
ShowConfirmation=1
ShowDoneMessage=0
• 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" />
// 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.