dlite922 1,584
Recognized Expert Top Contributor
Hey guys,
I've built applications and I've always wanted my own version and build number that's more like bigger applications.
Requirements:
1. The version should be manual (besides obviously there is no way for the app itself to know if it got a new feature vs a fix, I'd like to be the one starting new versions or sub-versions)
2. Build number should be automatic based on the most recently modified file.
My Idea:
1. Get all the project files and find the most recent file update time stamp
2. Calculate the build number based on given version number to get a value that's from hundreds to thousands long (I don't want to reach tens of thousands preferably)
I'm having trouble with the math for 2. Primarily how I can make the build look like it was reset when I change version number, say when I change the version value from 2.0.1 to 2.0.2 or 2.1.0
Maybe I should just store the date the version was changed when change the version value itself and calculate the number of hours from that TS (time stamp) and the last modified file TS.
I'm open to any other ideas.
Peace out,
Dan
5 5708 dlite922 1,584
Recognized Expert Top Contributor
current test code I'm playing around with: -
-
-
<?php
-
-
-
-
/**
-
* Gets entire file system recursively or non-recursivly in a given directory
-
*
-
* @param mixed $directory
-
* @param mixed $recursive
-
* @return array
-
*/
-
function getAllFiles($directory, $recursive = true)
-
{
-
$result = array();
-
-
if(is_dir($directory))
-
{
-
$handle = opendir($directory);
-
while ($datei = readdir($handle))
-
{
-
if (($datei != '.') && ($datei != '..')) {
-
$file = $directory.$datei;
-
if (is_dir($file)) {
-
if ($recursive) {
-
$result = array_merge($result, getAllFiles($file.'/'));
-
}
-
}
-
else {
-
$result[] = $file;
-
}
-
}
-
}
-
closedir($handle);
-
}
-
-
return $result;
-
}
-
-
/**
-
* Gets the most recent file TS in a directory
-
*
-
* @uses getAllFiles()
-
* @param mixed $directory
-
* @param mixed $recursive
-
* @return integer
-
*/
-
function getHighestFileTimestamp($directory, $recursive = true)
-
{
-
$allFiles = getAllFiles($directory, $recursive);
-
-
$highestKnown = 0;
-
foreach ($allFiles as $val)
-
{
-
$currentValue = filemtime($val);
-
if ($currentValue > $highestKnown) $highestKnown = $currentValue;
-
}
-
-
return $highestKnown;
-
}
-
-
-
/**
-
* Makes a build number based on newest file in the project and project version
-
* @uses getHighestFileTimestamp()
-
* @return integer
-
*/
-
function makeBuildNumber($version,$dir)
-
{
-
$newestFileTS = getHighestFileTimestamp($dir,true);
-
-
// TS is too large, subtract and version number + padding in thousands to get a build number
-
$verMx = intval(preg_replace('/[^0-9]/','',$version)) + 1257455304 * 1000;
-
-
return ($newestFileTS - $verMx);
-
}
-
-
echo makeBuildNumber("2.0.1","/path/to/project/");
-
-
see if you can get a better formula to work for line number 74 above.
Dan
dlite922 1,584
Recognized Expert Top Contributor
My best idea so far:
Build number is based on the 3rd version value. So when you change from 2.0.1 to 2.0.5 the build number grows as well. But will seem to have reset when you change to 2.0.1
psuedocode: -
-
$version = "2.0.2";
-
$multiplier = end(explode(".",$version)) * $othervalues;
-
-
ya? no? got a better idea?
Dan
Dormilich 8,658
Recognized Expert Moderator Expert @dlite922
I’d use the subversion (or whatever you use) revision number as build number.
dlite922 1,584
Recognized Expert Top Contributor @Dormilich
How would I display that on the main page of the app though? Every time I check anything into SVN i'd have to change the version number by hand, which is daily at the beginning phases of the project.
It would be cool if SVN would update a text file everytime you checked something in and I could read the file content.
Dan
Dormilich 8,658
Recognized Expert Moderator Expert
the latest revision number should be somewhere in .svn.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Whitney Kew |
last post by:
Hi,
Is there a programmatic way to get the "general" or "overall" version of a
currently running instance of the Visual Studio .NET compiler? What I mean
by "general" or "overall" version is, I want to programmatically get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\Microsoft\VisualStudio key, such as "7.0" or "7.1" (for .NET
2002 or .NET 2003, respectively). My registry contains both 7.0 and 7.1
keys,...
|
by: Sonoman |
last post by:
Hi all:
I am trying to write a simple program that simulates asking several persons
their birth day and it counts how many persons are asked until two have the
same birth day. The problem that I have is that the first loop I get a
sequence of random numbers untuil I get a match, BUT then on the following
loops I get the SAME random(?) sequence. I am using rand(). I do not want to
get too fancy with the random number generator, but is there...
|
by: Wahoo |
last post by:
Another question,my teacher gave me a code for
generate a random number from 1 - range, but I can't made it work, where is
the problem?
Thanks!!
|
by: Joe |
last post by:
Hi, I have been working on some code that requires a high use of random
numbers within. Mostly I either have to either:
1) flip a coin i.e. 0 or 1, or
2) generate a double between 0 and 1.
I have utilised the following random number source code
http://www.agner.org/random/
What I have found is that there is a problem with seeding. The code
generates a seed based on time(0). I have found that I need to increment
|
by: Djakobsson |
last post by:
Hi,
I have a SQL server DB for a document handeling system.
For the new version of the system the database have been updated with
some new tables, new stored procedures and updated stored procedures.
There is no changes in the existing tables that contains data.
What is the best way to update this DB?
I had planned to use the SQL script generator. Is there a problem with
this?
| |
by: mekim |
last post by:
Hello....I am trying to System.Reflection.Assembly.GetExecutingAssembly
().GetName
().Version.ToString () ;
to display the version of the app...but it remains static and therefore does
not increment...it's
AssemblyInfo.vb looks like this
|
by: John |
last post by:
Hi
How can I change the product version number that is returned by
Application.ProductVersion?
Thanks
Regards
|
by: Gavin Sullivan |
last post by:
I've been using the date (in YMMDD) format for the build number in the
AssemblyVersion attribute. However, it appears that numbers 65534 are
invalid!! Bit of a bummer for 2007!!!
Is there a reason for this? 65535 would make sense!?
Is there a work around, patch, etc??
Regards
|
by: ewingate |
last post by:
I cannot seem to get the version number of my VB app to increment
properly in VS2005. When I build the app each day the "build" number
increments with no problem as does the version number but if I make
multiple changes to my code during the day and then build again that
same day the version number will not change. I have the attribute set
to "1.0.*" and the default .NET formula of versioning is fine if only
it would update whenever I make...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |