Winforms: C#: Show Build Date in Form.

Bryan Valencia 1 Reputation point
2021-08-23T19:35:16.32+00:00

I have a .net Winforms App
I am using a Deployment Project to build an MSI installer.

Here's what I want:
When I do a build, I want the Build Date to be stored in the APPLICATION (not USER) Settings.
I then want to display that on the main form.
I do NOT want to update this value manually.

The users HATE trying to communicate with me based on build numbers. If I ask "Are you on 2.1.23 or 2.2.4? The first question is, "Is that the one from March, or June?"
I had this whole thing set up with Echo Date... in the pre-build events, but with the latest VS2019 updates and having to reinstall the Deployment Projects package, this no longer works.

All I want is to update the Build Date at Compile Time.

Notes:
NOT using Core.
NOT using ClickOnce.

Oh, and I also don't want to capture the date that the user first runs the app, like putting a dummy value in the app settings and replacing it if the dummy value is found.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,914 questions
{count} votes

6 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,461 Reputation points
    2021-09-21T10:28:14.067+00:00

    Okay, here is another option using a T4 template found here. Also read pro tip

    What the author does not indicate

    Under properties for BuildInfo.tt set Custom Tool to TextTemplatingFileGenerator, save the file and BuildInfo.cs is generated.

    When saving the .tt file and .cs class is generated then use to get the build date

    private void BuildInfo_Click(object sender, EventArgs e)
    {
        MessageBox.Show(BuildInfo.BuildDateText);
    }
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.