Setting a PropertySet variable to a calculated value

Hi:

I am using a PropertySet that uses the '.Net Assembly Info' contents and would like to know how I can set one of the values (BuildVersion) to a specific value, for instance, the number of days since 1-1-2000?

This value would be recalculated on each build.

Thanks,

MartinH.

 

 

Hi Martin,

You can use the "PropertySet Assign Properties" action to set the value of the 'BuildVersion' property. To set the value to the number of days since 1-1-2000, you will need to define a variable and use javascript to set the variable to the number of days since 1-1-2000. You can then set the 'BuildVersion' property to the value of the variable, using the syntax (%Variable_Name%).

Here is the javascript to calculate the days since 1-1-2000 saving the value into the variable 'BuildVer':

var currentDate = new Date();
var comparisonDate = new Date(2000, 0, 1);
var difference = currentDate - comparisonDate;

BuildVer = Math.floor(difference / 86400000);

Paul:

Thanks for the information, it's just what I was looking for.

I do, however, have a problem. I can't see how to implement the javascript or where. I have attached a small trial project so you can see what I have done so far (not very much!)

Thanks for your help,

Martin.

TestProject.zip (27.901 KB)

Hi Martin,

 

You can use the 'Run Script' action to execute the javascript. For more information see https://www.finalbuilder.com/finalbuilder/Help/HTML/runscriptaction.htm

 

Attached is the updated project which contains the javascript.

 

Regards,

Paul.

TestProject-Changed.zip (32.937 KB)