Add version number and versioning
Add missing project items

Add missing project items
This commit is contained in:
Geoffrey Fielden-Briggs 2019-06-05 14:12:50 -04:00
Родитель ffbe220b5f
Коммит d99af02c9d
9 изменённых файлов: 168 добавлений и 0 удалений

4
gitversion.yml Normal file
Просмотреть файл

@ -0,0 +1,4 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
next-version: 1.0.0

Просмотреть файл

@ -0,0 +1,32 @@
#if __ANDROID__
using System;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Input;
using Android.App;
namespace Uno.AzureDevOps.Framework.AppVersion
{
public static partial class VersionHelper
{
private static string GetAppVersion()
{
return Application.Context.GetType().Assembly.GetName().Version.ToString(4);
}
private static string GetBuildNumber()
{
string buildNumber = null;
var attribute = Application.Context.GetType().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>();
if (attribute != null)
{
buildNumber = attribute.Version;
}
return $"({buildNumber})";
}
}
}
#endif

Просмотреть файл

@ -0,0 +1,48 @@
#if NETFX_CORE
using System;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Input;
using Uno.Extensions;
using Windows.UI.Xaml;
namespace Uno.AzureDevOps.Framework.AppVersion
{
public static partial class VersionHelper
{
private static string GetAppVersion()
{
string appVersion;
try
{
appVersion = Application.Current.GetType().GetAssembly().GetName().Version.ToString(4);
}
catch
{
// Application.Current throws when running inside a background task
appVersion = null;
}
return appVersion;
}
private static string GetBuildNumber()
{
string buildNumber = null;
var appVersion = Application.Current.GetType().GetAssembly().GetName().Version;
var attribute = Application.Current.GetType().GetAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>();
if (attribute == null)
{
return buildNumber;
}
buildNumber = attribute.Version;
return $"({buildNumber})";
}
}
}
#endif

Просмотреть файл

@ -0,0 +1,21 @@
#if __WASM__
using System;
using System.Reflection;
namespace Uno.AzureDevOps.Framework.AppVersion
{
//Not working for wasm application.
public static partial class VersionHelper
{
private static string GetBuildNumber()
{
return null;
}
private static string GetAppVersion()
{
return null;
}
}
}
#endif

Просмотреть файл

@ -0,0 +1,12 @@
using System;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Uno.AzureDevOps.Framework.AppVersion
{
public static partial class VersionHelper
{
public static string GetAppVersionWithBuildNumber => $"{GetAppVersion()} {GetBuildNumber()}";
}
}

Просмотреть файл

@ -0,0 +1,27 @@
#if __IOS__
using System;
using System.Diagnostics;
using UIKit;
namespace Uno.AzureDevOps.Framework.AppVersion
{
public static partial class VersionHelper
{
private static string GetAppVersion()
{
return UIApplication.SharedApplication.Delegate.GetType().Assembly.GetName().Version.ToString(4);
}
private static string GetBuildNumber()
{
string buildNumber = null;
var versionInfo = FileVersionInfo.GetVersionInfo(UIApplication.SharedApplication.Delegate.GetType().Assembly.Location);
buildNumber = versionInfo.FileVersion;
return $"({buildNumber})";
}
}
}
#endif

Просмотреть файл

@ -6,6 +6,7 @@ using GalaSoft.MvvmLight.Ioc;
using Uno.AzureDevOps.Business.Authentication;
using Uno.AzureDevOps.Business.Extensions;
using Uno.AzureDevOps.Business.VSTS;
using Uno.AzureDevOps.Framework.AppVersion;
using Uno.AzureDevOps.Framework.Navigation;
using Uno.AzureDevOps.Framework.Tasks;
using Windows.System;
@ -18,6 +19,7 @@ namespace Uno.AzureDevOps.Presentation
private readonly IStackNavigationService _navigationService;
private readonly IAuthenticationService _authenticationService;
private readonly IVSTSRepository _vstsRespository;
private string _appVersion;
public ProfilePageViewModel()
{
@ -31,6 +33,8 @@ namespace Uno.AzureDevOps.Presentation
ReloadPage = new RelayCommand(() => ReloadPageCommand());
NavigateToSourceCode = new RelayCommand(async () => await Launcher.LaunchUriAsync(new Uri("https://github.com/nventive/uno.azuredevops")));
AppVersion = VersionHelper.GetAppVersionWithBuildNumber;
}
public ITaskNotifier<UserProfile> User { get; private set; }
@ -43,6 +47,12 @@ namespace Uno.AzureDevOps.Presentation
public ICommand NavigateToSourceCode { get; }
public string AppVersion
{
get => _appVersion;
set => Set(() => AppVersion, ref _appVersion, value);
}
private void ReloadPageCommand()
{
User = new TaskNotifier<UserProfile>(_vstsRespository.GetUserProfile());

Просмотреть файл

@ -85,6 +85,11 @@
<Compile Include="$(MSBuildThisFileDirectory)Framework\Tasks\ITaskNotifier.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Framework\Tasks\ITaskNotifier.Generic.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Framework\Tasks\TaskNotifier.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Framework\Version\VersionHelper.Android.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Framework\Version\VersionHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Framework\Version\VersionHelper.iOS.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Framework\Version\VersionHelper.UWP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Framework\Version\VersionHelper.Wasm.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Module.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Presentation\AboutPageViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Presentation\LoginPageViewModel.cs" />

Просмотреть файл

@ -152,6 +152,15 @@
Command="{Binding NavigateToSourceCode}"
Margin="0,-6,0,32" />
<!-- Version Number -->
<TextBlock Visibility="{Binding AppVersion, Converter={StaticResource EmptyStringToCollapsed}, FallbackValue=Collapsed}"
Style="{StaticResource Typo18}"
HorizontalAlignment="Center"
Margin="0,4,0,19">
<Run Text="Version" />
<Run Text="{Binding AppVersion}" />
</TextBlock>
<!-- Log out button -->
<Button Content="Log Out"
Style="{StaticResource PrimaryButtonStyle}"