Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VB.NET, project build date and version

Posted on 2004-08-17
15
1,554 Views
Last Modified: 2008-01-09
I wrote a project in VS 2k2 and we have since upgraded to 2k3.  I opened the project in 2k3, converted it to 2k3, and have been working on it.  One theing that has never worked was the versioning of the software.

How do I get the version to change each time I build (and how do I build it the right waty to make it keep doing that).

As a fix, we added in a way to view the date of the build...but so far it is just printing out a static date that I have to hard code in.  How would I go about creating a few lines of code to get the build date of the project upon execution for display?  How would I do this with the version as well?

Also, in my setup project, I have detect newer instal to true and remove previous version true, but it does not do either of these.  How do I get this to work?

Thank you
Majin Loki
0
Comment
Question by:MajinLoki
  • 8
  • 7
15 Comments
 
LVL 6

Expert Comment

by:pillbug22
ID: 11823483
For the version, look in the AssemblyInfo.vb file. There will be a line with (default entry):

<Assembly: AssemblyVersion("1.0.0.*")>

Take off the * and replace with your numbers to control the version. So, if you wanted version 2.1, then you would have:

<Assembly: AssemblyVersion("2.1")>
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 11823499
Just thought about it - for detecting the build date, you can put a routine in your code that is based on System.IO - basically grab the current application file and check the .DateCreated or .DateModified property on the file.
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 11823535
To print the version to the screen:

lblVersion.Text = "Version " & Application.ProductVersion
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Author Comment

by:MajinLoki
ID: 11833402
The version does not change with each build...so the version is always incorrect.
0
 
LVL 4

Author Comment

by:MajinLoki
ID: 11833416
How do I go about grabbing the current app file when it could be installed anywhere without prompting the user to pick the file?
0
 
LVL 6

Accepted Solution

by:
pillbug22 earned 125 total points
ID: 11834089
SO right now, the version doesn't change, but you want it to?

then in the assembly.vb file, find the

<Assembly: AssemblyVersion...>

line and make sure there is an * in the place of the number you want to increment automatically. i.e.:

<Assembly: AssemblyVersion("1.0.0.*")>

will make the version always start with 1.0.0, then the last number will increment with each build.



For grabbing the current file and getting the lst time it was modified, you can do something like:
(Imports System.IO)

        ' Application.ExecutablePath points to the folder where the app was started from
        Dim fFile As New FileInfo(Application.ExecutablePath & "<your EXE name")
        Dim sTime As String = fFile.LastWriteTime.ToString
0
 
LVL 4

Author Comment

by:MajinLoki
ID: 11841775
I have this line
<Assembly: AssemblyVersion("1.0.0.*")>

but it doesn't seem to update.  When I create a new install, it will not remove the previous version, even with that feature set to true.

basically what I want it to do is, for each install/build that we put out, the new one can just be run and will replace the old one.  I would like it to do this automatically.

the last time modified will be a great help.  Thank you.

Loki
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 11841859
I've never gotten the Remove Previous Version option to work with the install package. I've heard that all it does it flag the .msi file with those options, but must have a different installer package (like form InstallShield or Wise) to actually use those options.
0
 
LVL 4

Author Comment

by:MajinLoki
ID: 11841905
I tried to use the code you gave me and Application.ExecutablePath is giving me an error.

Name 'Application' is not declared.
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 11842019
0
 
LVL 4

Author Comment

by:MajinLoki
ID: 11842136
*lol*  now this is funny...I'm getting a bogus time and date.

12/31/1600 6:00:00 PM
0
 
LVL 4

Author Comment

by:MajinLoki
ID: 11842166
Oh, duh.  I think I have it figured out....I'm trying to test it in VS...but to correctly test it I will have to install the program on my machine.
0
 
LVL 4

Author Comment

by:MajinLoki
ID: 11842288
nope, I was wrong.  Still getting the bogus date.
0
 
LVL 4

Author Comment

by:MajinLoki
ID: 11842376
I got it.

Dim fFile As New FileInfo(Application.ExecutablePath & "<your EXE name")

needed to be

Dim fFile As New System.IO.FileInfo(System.Windows.Forms.Application.ExecutablePath)

Thanks!
0
 
LVL 6

Expert Comment

by:pillbug22
ID: 11842447
Or add System.IO as an Imports at the top of your code file.

(as per origonal code suggestion  :-)   )
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question