Add version to wizard
This commit is contained in:
Родитель
907ffd5169
Коммит
a29dde58ce
|
@ -162,16 +162,6 @@ namespace Microsoft.Templates.Core.Locations
|
|||
}
|
||||
}
|
||||
|
||||
public static string GetVersionFromFile(string versionFilePath)
|
||||
{
|
||||
var version = "0.0.0";
|
||||
if (File.Exists(versionFilePath))
|
||||
{
|
||||
version = File.ReadAllText(versionFilePath);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
private static void SafeCleanUpTempFolder(string usedTempFolder)
|
||||
{
|
||||
try
|
||||
|
|
|
@ -19,6 +19,12 @@ namespace Microsoft.Templates.Core.Locations
|
|||
public abstract void Adquire(string workingFolder);
|
||||
public abstract bool Update(string workingFolder);
|
||||
|
||||
public string GetVersion(string workingFolder)
|
||||
{
|
||||
var fileName = Path.Combine(workingFolder, Path.Combine(TemplatesName, VersionFileName));
|
||||
return GetVersionFromFile(fileName);
|
||||
}
|
||||
|
||||
protected static void SafeDelete(string directoryPath)
|
||||
{
|
||||
if (Directory.Exists(directoryPath))
|
||||
|
@ -50,5 +56,15 @@ namespace Microsoft.Templates.Core.Locations
|
|||
CopyRecursive(directory, Path.Combine(targetDir, Path.GetFileName(directory)));
|
||||
}
|
||||
}
|
||||
|
||||
protected static string GetVersionFromFile(string versionFilePath)
|
||||
{
|
||||
var version = "0.0.0";
|
||||
if (File.Exists(versionFilePath))
|
||||
{
|
||||
version = File.ReadAllText(versionFilePath);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,12 @@ namespace Microsoft.Templates.Core
|
|||
await AdquireContentAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public string GetVersion()
|
||||
{
|
||||
return _location.GetVersion(WorkingFolder);
|
||||
}
|
||||
|
||||
private async Task AdquireContentAsync()
|
||||
{
|
||||
SyncStatusChanged?.Invoke(this, SyncStatus.Adquiring);
|
||||
|
|
|
@ -39,8 +39,17 @@
|
|||
<ColumnDefinition Width="3*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Status}" />
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Status}" Style="{StaticResource StatusStyle}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Wizard:" Style="{StaticResource VersionTitleStyle}" />
|
||||
<TextBlock Text="{Binding WizardVersion}" Style="{StaticResource VersionValueStyle}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Templates:" Style="{StaticResource VersionTitleStyle}" />
|
||||
<TextBlock Text="{Binding TemplatesVersion}" Style="{StaticResource VersionValueStyle}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1" Style="{StaticResource NavigationContainerStyle}">
|
||||
<Button Style="{StaticResource NavigationButtonStyle}" Content="{x:Static local:WizardHostResources.CancelButton}" Command="{Binding CancelCommand}" />
|
||||
<Button Style="{StaticResource NavigationButtonStyle}" Content="{x:Static local:WizardHostResources.PreviousButton}" Command="{Binding PreviousCommand}" />
|
||||
|
|
|
@ -8,6 +8,7 @@ using Microsoft.Templates.Wizard.Steps;
|
|||
using Microsoft.Templates.Wizard.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
@ -57,8 +58,12 @@ namespace Microsoft.Templates.Wizard.Host
|
|||
|
||||
try
|
||||
{
|
||||
WizardVersion = GetWizardVersion();
|
||||
|
||||
await GenContext.ToolBox.Repo.SynchronizeAsync();
|
||||
Status = string.Empty;
|
||||
|
||||
TemplatesVersion = GenContext.ToolBox.Repo.GetVersion();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -69,6 +74,14 @@ namespace Microsoft.Templates.Wizard.Host
|
|||
}
|
||||
}
|
||||
|
||||
private string GetWizardVersion()
|
||||
{
|
||||
string assemblyLocation = Assembly.GetExecutingAssembly().Location;
|
||||
var versionInfo = FileVersionInfo.GetVersionInfo(assemblyLocation);
|
||||
|
||||
return versionInfo.FileVersion;
|
||||
}
|
||||
|
||||
private string GetStatusText(SyncStatus status)
|
||||
{
|
||||
switch (status)
|
||||
|
@ -93,6 +106,20 @@ namespace Microsoft.Templates.Wizard.Host
|
|||
set { SetProperty(ref _status, value); }
|
||||
}
|
||||
|
||||
private string _wizardVersion;
|
||||
public string WizardVersion
|
||||
{
|
||||
get { return _wizardVersion; }
|
||||
set { SetProperty(ref _wizardVersion, value); }
|
||||
}
|
||||
|
||||
private string _templatesVersion;
|
||||
public string TemplatesVersion
|
||||
{
|
||||
get { return _templatesVersion; }
|
||||
set { SetProperty(ref _templatesVersion, value); }
|
||||
}
|
||||
|
||||
private string _stepTitle;
|
||||
public string StepTitle
|
||||
{
|
||||
|
|
|
@ -29,10 +29,24 @@
|
|||
<Style TargetType="Button" x:Key="NavigationButtonStyle">
|
||||
<Setter Property="Margin" Value="{StaticResource ShortLeftMargin}" />
|
||||
<Setter Property="Width" Value="75" />
|
||||
<Setter Property="Height" Value="24" />
|
||||
</Style>
|
||||
<Style TargetType="Frame" x:Key="StepContainerStyle">
|
||||
<Setter Property="Margin" Value="10" />
|
||||
</Style>
|
||||
|
||||
|
||||
<Style TargetType="TextBlock" x:Key="StatusStyle">
|
||||
<Setter Property="Margin" Value="{StaticResource ShortBottomMargin}" />
|
||||
</Style>
|
||||
<Style TargetType="TextBlock" x:Key="VersionTitleStyle">
|
||||
<Setter Property="FontSize" Value="10" />
|
||||
<Setter Property="FontWeight" Value="SemiBold" />
|
||||
</Style>
|
||||
<Style TargetType="TextBlock" x:Key="VersionValueStyle">
|
||||
<Setter Property="FontSize" Value="10" />
|
||||
<Setter Property="FontStyle" Value="Italic" />
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Grid" x:Key="TemplatesContainerStyle">
|
||||
<Setter Property="Margin" Value="{StaticResource MediumTopMargin}" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче