weeklyxamarin / WeeklyXamarin.mobile

Mobile Application for Weekly Xamarin
MIT License
87 stars 30 forks source link

Display version with build date/time #69

Closed smabuk closed 3 years ago

smabuk commented 3 years ago

What it does

Background

There are a few ways that this can be achieved, but this is the simplified version I'm using for Blazor projects.

I would normally include a full code block in the csproj a bit like this

  <PropertyGroup>
    <Authors>Simon Brookes</Authors>
    <Company>Simon Brookes</Company>
    <Copyright>Copyright © Simon Brookes</Copyright>
    <Description></Description>
    <VersionPrefix>0.8.20</VersionPrefix>
    <VersionSuffix Condition=" '$(ComputerName)' != '' ">$(ComputerName)-$([System.DateTime]::get_Now().get_Year())$([System.DateTime]::get_Now().get_Month().ToString("D2"))$([System.DateTime]::get_Now().get_Day().ToString("D2"))-$([System.DateTime]::get_Now().get_Hour().ToString("D2"))$([System.DateTime]::get_Now().get_Minute().ToString("D2"))</VersionSuffix>
    <VersionSuffix Condition=" '$(ComputerName)' == '' ">$([System.DateTime]::get_Now().get_Year())$([System.DateTime]::get_Now().get_Month().ToString("D2"))$([System.DateTime]::get_Now().get_Day().ToString("D2"))-$([System.DateTime]::get_Now().get_Hour().ToString("D2"))$([System.DateTime]::get_Now().get_Minute().ToString("D2"))</VersionSuffix>
  </PropertyGroup>

If you want to see the sort of thing that can be done with MSBuild and versioning I made a sample repository about 4 years ago when I was still primarily working in VB.NET.

Versioning Demos