Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Refactor versioning strategy to use csproj

supporta0e2ad9e7ee6
diff --git a/src/Build/Grand.Common.props b/src/Build/Grand.Common.props
index 6087a84af..8ef9f53ff 100644
--- a/src/Build/Grand.Common.props
+++ b/src/Build/Grand.Common.props
@@ -34,4 +34,9 @@
<ItemGroup Condition="'$(GitBranch)'!=''">
<AssemblyMetadata Include="GitBranch" Value="$(GitBranch)" />
</ItemGroup>
+ <Target Name="SetVersion" BeforeTargets="PrepareForBuild">
+ <PropertyGroup>
+ <Version>2.2.0-develop</Version>
+ </PropertyGroup>
+ </Target>
</Project>
diff --git a/src/Core/Grand.Infrastructure/GrandVersion.cs b/src/Core/Grand.Infrastructure/GrandVersion.cs
index 4344710dd..b9275d63b 100644
--- a/src/Core/Grand.Infrastructure/GrandVersion.cs
+++ b/src/Core/Grand.Infrastructure/GrandVersion.cs
@@ -1,4 +1,5 @@
using System.Reflection;
+using System.Text.RegularExpressions;
namespace Grand.Infrastructure
{
@@ -7,32 +8,44 @@ namespace Grand.Infrastructure
/// <summary>
/// Gets the major version
/// </summary>
- public const string MajorVersion = "2";
+ public static readonly string MajorVersion = Assembly.GetExecutingAssembly().GetName().Version?.Major.ToString();
/// <summary>
/// Gets the minor version
/// </summary>
- public const string MinorVersion = "2";
+ public static readonly string MinorVersion = Assembly.GetExecutingAssembly().GetName().Version?.Minor.ToString();
/// <summary>
/// Gets the patch version
/// </summary>
- public const string PatchVersion = "0-develop";
-
+ public static string PatchVersion {
+ get {
+
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ if (assembly.GetCustomAttribute(typeof(AssemblyInformationalVersionAttribute)) is not
+ AssemblyInformationalVersionAttribute infoVersionAttribute) return "0";
+ var fullVersion = infoVersionAttribute.InformationalVersion;
+ Match match = Regex.Match(fullVersion, @"(\d+)\.(\d+)\.(\d+)(?:-([^\+]+))?");
+ if (!match.Success) return "0";
+ var patch = match.Groups[3].Value;
+ var suffix = match.Groups[4].Value;
+ return string.IsNullOrEmpty(suffix) ? patch : $"{patch}-{suffix}";
+ }
+ }
/// <summary>
/// Gets the full version
/// </summary>
- public const string FullVersion = $"{MajorVersion}.{MinorVersion}.{PatchVersion}";
+ public static readonly string FullVersion = $"{MajorVersion}.{MinorVersion}.{PatchVersion}";
/// <summary>
/// Gets the Supported DB version
/// </summary>
- public const string SupportedDBVersion = $"{MajorVersion}.{MinorVersion}";
+ public static readonly string SupportedDBVersion = $"{MajorVersion}.{MinorVersion}";
/// <summary>
/// Gets the Supported plugin version
/// </summary>
- public const string SupportedPluginVersion = $"{MajorVersion}.{MinorVersion}";
+ public static readonly string SupportedPluginVersion = $"{MajorVersion}.{MinorVersion}";
/// <summary>
/// Gets the git branch
diff --git a/src/Core/Grand.Infrastructure/Plugins/PluginInfoAttribute.cs b/src/Core/Grand.Infrastructure/Plugins/PluginInfoAttribute.cs
index 94b6ebc70..c91e97de0 100644
--- a/src/Core/Grand.Infrastructure/Plugins/PluginInfoAttribute.cs
+++ b/src/Core/Grand.Infrastructure/Plugins/PluginInfoAttribute.cs
@@ -1,13 +1,24 @@
-namespace Grand.Infrastructure.Plugins
+using System.Reflection;
+
+namespace Grand.Infrastructure.Plugins
{
[AttributeUsage(AttributeTargets.Assembly)]
public class PluginInfoAttribute : Attribute
{
+ public PluginInfoAttribute()
+ {
+ Assembly assembly = Assembly.GetExecutingAssembly();
+ Version fullVersion = assembly.GetName().Version;
+ SupportedVersion = $"{fullVersion?.Minor}.{fullVersion?.Major}";
+
+ }
public string Group { get; set; } = string.Empty;
public string FriendlyName { get; set; } = string.Empty;
public string SystemName { get; set; } = string.Empty;
public string Author { get; set; } = string.Empty;
+
public string SupportedVersion { get; set; }
+
public string Version { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Plugins/Authentication.Facebook/Manifest.cs b/src/Plugins/Authentication.Facebook/Manifest.cs
index f2fa48230..c56063a73 100644
--- a/src/Plugins/Authentication.Facebook/Manifest.cs
+++ b/src/Plugins/Authentication.Facebook/Manifest.cs
@@ -1,12 +1,10 @@
using Authentication.Facebook;
-using Grand.Infrastructure;
using Grand.Infrastructure.Plugins;
[assembly: PluginInfo(
FriendlyName = "Facebook authentication",
Group = "Authentication methods",
SystemName = FacebookAuthenticationDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Authentication.Google/Manifest.cs b/src/Plugins/Authentication.Google/Manifest.cs
index 331ec8d2c..a8dc2de87 100644
--- a/src/Plugins/Authentication.Google/Manifest.cs
+++ b/src/Plugins/Authentication.Google/Manifest.cs
@@ -1,12 +1,10 @@
using Authentication.Google;
-using Grand.Infrastructure;
using Grand.Infrastructure.Plugins;
[assembly: PluginInfo(
FriendlyName = "Google authentication",
Group = "Authentication methods",
SystemName = GoogleAuthenticationDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/DiscountRules.Standard/Manifest.cs b/src/Plugins/DiscountRules.Standard/Manifest.cs
index c3b9de4bf..f46292c58 100644
--- a/src/Plugins/DiscountRules.Standard/Manifest.cs
+++ b/src/Plugins/DiscountRules.Standard/Manifest.cs
@@ -1,11 +1,9 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
[assembly: PluginInfo(
FriendlyName = "Standard discount requirements",
Group = "Discount requirements",
SystemName = "DiscountRules.Standard",
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
diff --git a/src/Plugins/ExchangeRate.McExchange/Manifest.cs b/src/Plugins/ExchangeRate.McExchange/Manifest.cs
index f7fa51dc7..fb8c6157e 100644
--- a/src/Plugins/ExchangeRate.McExchange/Manifest.cs
+++ b/src/Plugins/ExchangeRate.McExchange/Manifest.cs
@@ -1,11 +1,9 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
[assembly: PluginInfo(
FriendlyName = "Money converter exchange rate provider (from EUR: ECB, from PLN: NBP)",
Group = "Exchange rate providers",
SystemName = "CurrencyExchange.MoneyConverter",
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Payments.BrainTree/Manifest.cs b/src/Plugins/Payments.BrainTree/Manifest.cs
index fb84cc94f..da981abed 100644
--- a/src/Plugins/Payments.BrainTree/Manifest.cs
+++ b/src/Plugins/Payments.BrainTree/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Payments.BrainTree;
[assembly: PluginInfo(
FriendlyName = "BrainTree",
Group = "Payment methods",
SystemName = BrainTreeDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Payments.CashOnDelivery/Manifest.cs b/src/Plugins/Payments.CashOnDelivery/Manifest.cs
index 88762f4fa..98e67eef9 100644
--- a/src/Plugins/Payments.CashOnDelivery/Manifest.cs
+++ b/src/Plugins/Payments.CashOnDelivery/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Payments.CashOnDelivery;
[assembly: PluginInfo(
FriendlyName = "Cash On Delivery (COD)",
Group = "Payment methods",
SystemName = CashOnDeliveryPaymentDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Payments.PayPalStandard/Manifest.cs b/src/Plugins/Payments.PayPalStandard/Manifest.cs
index af3ad3e2a..94d99b8ed 100644
--- a/src/Plugins/Payments.PayPalStandard/Manifest.cs
+++ b/src/Plugins/Payments.PayPalStandard/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Payments.PayPalStandard;
[assembly: PluginInfo(
FriendlyName = "PayPal Standard",
Group = "Payment methods",
SystemName = PayPalStandardPaymentDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Shipping.ByWeight/Manifest.cs b/src/Plugins/Shipping.ByWeight/Manifest.cs
index 97b20e129..ae98a9c21 100644
--- a/src/Plugins/Shipping.ByWeight/Manifest.cs
+++ b/src/Plugins/Shipping.ByWeight/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Shipping.ByWeight;
[assembly: PluginInfo(
FriendlyName = "Shipping by weight",
Group = "Shipping rate",
SystemName = ByWeightShippingDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Shipping.FixedRateShipping/Manifest.cs b/src/Plugins/Shipping.FixedRateShipping/Manifest.cs
index 1b9b79d3c..b1495122e 100644
--- a/src/Plugins/Shipping.FixedRateShipping/Manifest.cs
+++ b/src/Plugins/Shipping.FixedRateShipping/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Shipping.FixedRateShipping;
[assembly: PluginInfo(
FriendlyName = "Fixed Rate Shipping",
Group = "Shipping rate",
SystemName = FixedRateShippingDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Shipping.ShippingPoint/Manifest.cs b/src/Plugins/Shipping.ShippingPoint/Manifest.cs
index 0240b16af..88a5a8c56 100644
--- a/src/Plugins/Shipping.ShippingPoint/Manifest.cs
+++ b/src/Plugins/Shipping.ShippingPoint/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Shipping.ShippingPoint;
[assembly: PluginInfo(
FriendlyName = "Shipping Point",
Group = "Shipping rate",
SystemName = ShippingPointRateDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Tax.CountryStateZip/Manifest.cs b/src/Plugins/Tax.CountryStateZip/Manifest.cs
index 09d2f89bf..727b2f16c 100644
--- a/src/Plugins/Tax.CountryStateZip/Manifest.cs
+++ b/src/Plugins/Tax.CountryStateZip/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Tax.CountryStateZip;
[assembly: PluginInfo(
FriendlyName = "Tax By Country & State & Zip",
Group = "Tax providers",
SystemName = CountryStateZipTaxDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Tax.FixedRate/Manifest.cs b/src/Plugins/Tax.FixedRate/Manifest.cs
index 050aae708..de06cd375 100644
--- a/src/Plugins/Tax.FixedRate/Manifest.cs
+++ b/src/Plugins/Tax.FixedRate/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Tax.FixedRate;
[assembly: PluginInfo(
FriendlyName = "Fixed tax rate provider",
Group = "Tax providers",
SystemName = FixedRateTaxDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Widgets.FacebookPixel/Manifest.cs b/src/Plugins/Widgets.FacebookPixel/Manifest.cs
index e39dd1e99..7b8c7a2cf 100644
--- a/src/Plugins/Widgets.FacebookPixel/Manifest.cs
+++ b/src/Plugins/Widgets.FacebookPixel/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Widgets.FacebookPixel;
[assembly: PluginInfo(
FriendlyName = "Facebook Pixel",
Group = "Widgets",
SystemName = FacebookPixelDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Widgets.GoogleAnalytics/Manifest.cs b/src/Plugins/Widgets.GoogleAnalytics/Manifest.cs
index 0679acc64..1decc0427 100644
--- a/src/Plugins/Widgets.GoogleAnalytics/Manifest.cs
+++ b/src/Plugins/Widgets.GoogleAnalytics/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Widgets.GoogleAnalytics;
[assembly: PluginInfo(
FriendlyName = "Google Analytics or Universal Analytics",
Group = "Widgets",
SystemName = GoogleAnalyticDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.1"
)]
\ No newline at end of file
diff --git a/src/Plugins/Widgets.Slider/Manifest.cs b/src/Plugins/Widgets.Slider/Manifest.cs
index fa58d8660..a672a607c 100644
--- a/src/Plugins/Widgets.Slider/Manifest.cs
+++ b/src/Plugins/Widgets.Slider/Manifest.cs
@@ -1,12 +1,10 @@
-using Grand.Infrastructure;
-using Grand.Infrastructure.Plugins;
+using Grand.Infrastructure.Plugins;
using Widgets.Slider;
[assembly: PluginInfo(
FriendlyName = "Bootstrap Slider",
Group = "Widgets",
SystemName = SliderWidgetDefaults.ProviderSystemName,
- SupportedVersion = GrandVersion.SupportedPluginVersion,
Author = "grandnode team",
Version = "2.1.2"
)]
\ No newline at end of file
diff --git a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
index 9f2fc04b7..030b041b0 100644
--- a/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
+++ b/src/Web/Grand.Web.Admin/Controllers/PluginController.cs
@@ -423,7 +423,7 @@ namespace Grand.Web.Admin.Controllers
{
var assembly = Assembly.Load(ToByteArray(unzippedEntryStream));
var pluginInfo = assembly.GetCustomAttribute<PluginInfoAttribute>();
- if (pluginInfo is { SupportedVersion: GrandVersion.SupportedPluginVersion })
+ if (pluginInfo != null && pluginInfo.SupportedVersion == GrandVersion.SupportedPluginVersion)
{
supportedVersion = true;
_fpath = entry.FullName[..entry.FullName.LastIndexOf("/", StringComparison.Ordinal)];