I want to use VersionTask from MSBuild Community Tasks to set the calculation type of Revision. However, I hardly understand how to actually include a task in my csproj file.
The project has AssemblyInfo.cs, which has the following attribute:
[assembly: AssemblyVersion("3.2.5.*")]
What I want to do is to redo the processing of the Revision processing with my own custom processing.
I put the custom Version task in the csproj file as follows:
<UsingTask TaskName="MyCo.Build.Tasks.Version" AssemblyFile="$(SolutionDir)\..\Build\.build\MyCo.Build.Tasks.dll" />
The actual task is then called as follows:
<Target Name="BeforeBuild"> <Message Text="Setting Revision Number to $(BuildNumber)" /> <MyCo.Build.Tasks.Version RevisionType="BuildServerNumber" Revision="$(BuildNumber)" /></Target>
I see the target BeforeBuild being invoked due to the Message task, but the exe file still has the standard generated numbering as follows: File version: 3.2.5.27547
I was expecting something like 3.2.5.111 (build number passed to MSBuild as a parameter).
Since the Version task overrides the default processing of the "*" value for version 1, I donβt think it is necessary to actually modify the AssemblyInfo.cs file.
Do I need to pass the output value from the Version task to the MSBuild parameter? Do I really need to use the AssemblyVersion task to update the values ββin the file?
Obviously, I'm trying not to modify AssemblyInfo.cs, I just want to override version number handling.
Can anyone advise?
EDIT: I just found the following usage example in a chm file from the installer, which partially answers my question.
<Version BuildType="Automatic" RevisionType="Automatic" Major="1" Minor="3" > <Output TaskParameter="Major" PropertyName="Major" /> <Output TaskParameter="Minor" PropertyName="Minor" /> <Output TaskParameter="Build" PropertyName="Build" /> <Output TaskParameter="Revision" PropertyName="Revision" /> </Version> <Message Text="Version: $(Major).$(Minor).$(Build).$(Revision)"/>
However, when I run the assembly, I can output the generated version of the assembly to the Message task, but the exe file still has the default version, as before