Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(new): application version #3

Open
wants to merge 1 commit into
base: development-app-deployment-manifest
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cmf-cli/Commands/new/BusinessCommand.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO.Abstractions;
using System.Text.Json;
using Cmf.CLI.Constants;
using Cmf.CLI.Core;
using Cmf.CLI.Core.Attributes;
Expand Down Expand Up @@ -43,6 +41,13 @@ protected override List<string> GenerateArgs(IDirectoryInfo projectRoot, IDirect
var baseLayer = ExecutionContext.Instance.ProjectConfig.BaseLayer ?? CliConstants.DefaultBaseLayer;
includeMESNugets = baseLayer == BaseLayer.MES;
Log.Debug($"Project is targeting base layer {baseLayer}, so scaffolding {(includeMESNugets ? "with" : "without")} MES nugets.");

args.AddRange(new[]
{
"--app", (ExecutionContext.Instance.ProjectConfig.RepositoryType == RepositoryType.App).ToString(),
"--fileVersion", $"{mesVersion}.0",
"--assemblyVersion", $"{mesVersion.Major}.{mesVersion.Minor}.0.0",
});
}

// calculate relative path to local environment and create a new symbol for it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,35 @@
"type": "parameter",
"datatype": "bool",
"defaultValue": true
},
"app": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "False",
"description": "Indicates that repository type is app if true"
},
"fileVersion": {
"type": "parameter",
"datatype": "string",
"replaces": "<%= $CLI_PARAM_fileVersion %>"
},
"assemblyVersion": {
"type": "parameter",
"datatype": "string",
"replaces": "<%= $CLI_PARAM_assemblyVersion %>"
}
},
"sources": [
{
"modifiers": [
{
"condition": "!app",
"exclude": [
"Business.Package/ApplicationVersion/**",
"Business.Package/ApplicationVersion/"
]
}
]
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@

#region Using Directives

using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Reflection;

using Cmf.Foundation.ApplicationVersion;


#endregion Using Directives

namespace Cmf.<%= $CLI_PARAM_Tenant %>.ApplicationVersion
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project name instead of Tenant

{
/// <summary>
/// NRepresents the application version information gathering.
/// </summary>
[Export(typeof(IApplicationVersionInfo))]
public sealed class <%= $CLI_PARAM_Tenant %>VersionInfo : IApplicationVersionInfo
{
#region Properties

/// <summary>
/// Gets or sets the application build date.
/// </summary>
public DateTime BuildDate
{
get;
set;
}

/// <summary>
/// Gets or sets the build number of the file.
/// </summary>
public int FileBuildPart
{
get;
set;
}

/// <summary>
/// Gets or sets the major part of the file version number.
/// </summary>
public int FileMajorPart
{
get;
set;
}

/// <summary>
/// Gets or sets the minor part of the file version number.
/// </summary>
public int FileMinorPart
{
get;
set;
}

/// <summary>
/// Gets or sets the file private part.
/// </summary>
/// <value>
/// The file private part.
/// </value>
public int FilePrivatePart
{
get;
set;
}

/// <summary>
/// Gets or sets the build of the product this file is associated with.
/// </summary>
public int ProductBuildPart
{
get;
set;
}

/// <summary>
/// Gets or sets the major part of the file version number.
/// </summary>
public int ProductMajorPart
{
get;
set;
}

/// <summary>
/// Gets or sets the minor part of the product this file is associated with.
/// </summary>
public int ProductMinorPart
{
get;
set;
}

/// <summary>
/// Gets or sets the product name.
/// </summary>
public string ProductName
{
get;
set;
}

/// <summary>
/// Gets or sets the product private part.
/// </summary>
/// <value>
/// The product private part.
/// </value>
public int ProductPrivatePart
{
get;
set;
}

#endregion

#region Constructors
#endregion

#region Private & Internal Methods
#endregion

#region Public Methods

/// <summary>
/// Gets the version information.
/// </summary>
public void GetVersionInfo()
{
Assembly asm = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
FileInfo fi = new FileInfo(asm.Location);

Version version = asm.GetName().Version;

this.FileMajorPart = fvi.FileMajorPart;
this.FileMinorPart = fvi.FileMinorPart;
this.FileBuildPart = fvi.FileBuildPart;
this.FilePrivatePart = fvi.FilePrivatePart;
this.BuildDate = fi.LastWriteTimeUtc.ToLocalTime();

this.ProductMajorPart = version.Major;
this.ProductMinorPart = version.Minor;
this.ProductBuildPart = version.Build;
this.ProductPrivatePart = version.Revision;

this.ProductName = fvi.ProductName;
}

#endregion

#region Event handling Methods
#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyTitle>ApplicationVersion</AssemblyTitle>
<RootNamespace>Cmf.Custom.<%= $CLI_PARAM_idSegment %>.ApplicationVersion</RootNamespace>
<AssemblyName>Cmf.<%= $CLI_PARAM_Tenant %>.ApplicationVersion</AssemblyName>
<Product><%= $CLI_PARAM_Tenant %></Product>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AssemblyVersion><%= $CLI_PARAM_assemblyVersion %></AssemblyVersion>
<FileVersion><%= $CLI_PARAM_fileVersion %></FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputPath>..\..\LocalEnvironment\BusinessTier</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<OutputPath>..\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cmf.Foundation.ApplicationVersion" Version="10.2.1" />
<PackageReference Include="System.ComponentModel.Composition" Version="6.0.0" />
<PackageReference Include="System.Composition.AttributedModel" Version="7.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cmf.Custom.<%= $CLI_PARAM_i
{6C3D698D-7F9E-4E39-A571-DEB63582CA52} = {6C3D698D-7F9E-4E39-A571-DEB63582CA52}
EndProjectSection
EndProject
#if (app)
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Version", "ApplicationVersion\Version.csproj", "{2F05799E-8030-4B25-98B7-2BACF606E7B1}"
EndProject
#endif
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion core/Enums/PackageType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ public enum PackageType
/// </summary>
ProductDatabase = 15,
}
}
}