This powershell script might do what you want, although my recommendation would be to update the AssemblyInfo.cs file from FinalBuilder rather than the other way around.
# Define the assembly we want to load - a random reference assembly from SDK 3.0 $Pshfile="C:\myassembl.dll"
# Now load the assembly $Myasm= [System.Reflection.Assembly]::Loadfile($Pshfile)
# Get name, version and display the results $Aname=$Myasm.GetName() $Aver=$Aname.version
I get an error message with your example, so I changed it to the following:
{ # Define the assembly we want to load $FileName = "%ProjectOutputDir%\%ProjectName%.exe"
# Load the assembly $Assembly = [System.Reflection.Assembly]::Loadfile($FileName)
# Get version $Version = $Assembly.GetName().Version
# Store version in a Finalbuilder variable $FBVariables.SetVariable ("ProjectFullVersion") = $Version }
But now I get the following error message:
Unexpected token '(' in expression or statement. At line:12 char:27 + $FBVariables.SetVariable (" <<<< ProjectFullVersion") = $Version
Any ideas?
I'm using an AssemblyUpdater action to set the assembly version to %ProjectMajorVersionNumber%.%ProjectMinorVersionNumber%.*
Finally I would like to set the revisionnumber and buildnumber directly via Finalbuilder, but with the same calculation as happens in Visual Studio. So the build number should be the number of days after 1-1-2000 and the revision number should be number of seconds since midnight, divided by 2. But I don't know yet how to calculate those values in Finalbuilder....
Well, the Powershell script did run without an error, but the ProjectFullVersion variable kept empty....I have no clue what went wrong, so I started to do it in another way. I have now a 'Run Script' action at the start of my Finalbuilder project and that works okay. Contents of that (java) script:
var Now = new Date(); var _1_January_2000 = new Date (2000, 0, 1); var NrOfMilliSecondsPerDay = 24 * 60 * 60 * 1000; var NrOfMinutesPerHour = 60; var NrOfSecondsPerMinute = 60; var NrOfSecondsPerHour = NrOfMinutesPerHour * NrOfSecondsPerMinute;
// determine the number of days between now and 1 January 2000 var DifferenceInMilliSeconds = Math.abs (Now.getTime() - _1_January_2000.getTime()); var DifferenceInDays = Math.floor (DifferenceInMilliSeconds / NrOfMilliSecondsPerDay);
ProjectBuildNumber = DifferenceInDays;
// determine the number of seconds between now and midnight var DifferenceInSeconds = (Now.getHours() * NrOfSecondsPerHour) + (Now.getMinutes() * NrOfSecondsPerMinute) + (Now.getSeconds());