Browse Source

Get CLI & template version from the assembly.

pull/1089/head
Halil ibrahim Kalkan 8 years ago
parent
commit
f5f987189d
  1. 9
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs
  2. 5
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs
  3. 12
      framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs

9
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs

@ -1,4 +1,6 @@
using Microsoft.Extensions.DependencyInjection; using System;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.Commands;
@ -8,6 +10,8 @@ namespace Volo.Abp.Cli
{ {
public class CliService : ITransientDependency public class CliService : ITransientDependency
{ {
public static string Version => typeof(AbpCliCoreModule).Assembly.GetFileVersion();
protected ICommandLineArgumentParser CommandLineArgumentParser { get; } protected ICommandLineArgumentParser CommandLineArgumentParser { get; }
protected ICommandSelector CommandSelector { get; } protected ICommandSelector CommandSelector { get; }
public IHybridServiceScopeFactory ServiceScopeFactory { get; } public IHybridServiceScopeFactory ServiceScopeFactory { get; }
@ -24,6 +28,9 @@ namespace Volo.Abp.Cli
public async Task RunAsync(string[] args) public async Task RunAsync(string[] args)
{ {
Console.WriteLine("ABP CLI (abp.io)");
Console.WriteLine("Version: " + Version);
var commandLineArgs = CommandLineArgumentParser.Parse(args); var commandLineArgs = CommandLineArgumentParser.Parse(args);
var commandType = CommandSelector.Select(commandLineArgs); var commandType = CommandSelector.Select(commandLineArgs);

5
framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Cli;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.SolutionTemplating; using Volo.Abp.SolutionTemplating;
using Volo.Abp.SolutionTemplating.Building; using Volo.Abp.SolutionTemplating.Building;
@ -19,8 +20,6 @@ namespace Volo.Abp.ProjectBuilding
public async Task<ProjectBuildResult> BuildAsync(ProjectBuildArgs args) public async Task<ProjectBuildResult> BuildAsync(ProjectBuildArgs args)
{ {
var version = "0.16.0"; //TODO: Should get from somewhere!
var templateInfo = GetTemplateInfo(args); var templateInfo = GetTemplateInfo(args);
args.TemplateName = templateInfo.Name; args.TemplateName = templateInfo.Name;
@ -33,6 +32,8 @@ namespace Volo.Abp.ProjectBuilding
} }
} }
var version = CliService.Version;
var templateFile = await TemplateStore.GetAsync(args.TemplateName, version); var templateFile = await TemplateStore.GetAsync(args.TemplateName, version);
var context = new ProjectBuildContext( var context = new ProjectBuildContext(

12
framework/src/Volo.Abp.Core/System/Reflection/AbpAssemblyExtensions.cs

@ -0,0 +1,12 @@
using System.Diagnostics;
namespace System.Reflection
{
public static class AbpAssemblyExtensions
{
public static string GetFileVersion(this Assembly assembly)
{
return FileVersionInfo.GetVersionInfo(assembly.Location).FileVersion;
}
}
}
Loading…
Cancel
Save