Bladeren bron

Correcting .NET assembly version update during build, broken by 425dfa1050 Shared definition of assembly version + Dev build does not do version check

Source commit: 3ab22033d7b1da7818b3a1f7db45d8bb7cc01aee
Martin Prikryl 9 jaren geleden
bovenliggende
commit
472980fce2
3 gewijzigde bestanden met toevoegingen van 26 en 32 verwijderingen
  1. 1 17
      dotnet/Session.cs
  2. 20 13
      dotnet/internal/ExeSessionProcess.cs
  3. 5 2
      dotnet/properties/AssemblyInfo.cs

+ 1 - 17
dotnet/Session.cs

@@ -69,7 +69,7 @@ namespace WinSCP
         public string AdditionalExecutableArguments { get { return _additionalExecutableArguments; } set { CheckNotOpened(); _additionalExecutableArguments = value; } }
         [Obsolete("Use AddRawConfiguration")]
         public bool DefaultConfiguration { get { return _defaultConfiguration; } set { CheckNotOpened(); _defaultConfiguration = value; } }
-        public bool DisableVersionCheck { get { return GetDisableVersionCheck(); } set { CheckNotOpened(); _disableVersionCheck = value; } }
+        public bool DisableVersionCheck { get { return _disableVersionCheck; } set { CheckNotOpened(); _disableVersionCheck = value; } }
         [Obsolete("Use AddRawConfiguration")]
         public string IniFilePath { get { return _iniFilePath; } set { CheckNotOpened(); _iniFilePath = value; } }
         public TimeSpan ReconnectTime { get { return _reconnectTime; } set { CheckNotOpened(); _reconnectTime = value; } }
@@ -1922,22 +1922,6 @@ namespace WinSCP
             }
         }
 
-        private bool GetDisableVersionCheck()
-        {
-            bool result = _disableVersionCheck;
-
-            #if DEBUG
-            string env = Environment.GetEnvironmentVariable("WINSCPNET_DISABLE_VERSION_CHECK");
-            int envFlag;
-            if (!string.IsNullOrEmpty(env) && int.TryParse(env, out envFlag))
-            {
-                result = (envFlag != 0);
-            }
-            #endif
-
-            return result;
-        }
-
         private static string GetTypeLibKey(Type t)
         {
             return "CLSID\\{" + t.GUID.ToString().ToUpperInvariant() + "}\\TypeLib";

+ 20 - 13
dotnet/internal/ExeSessionProcess.cs

@@ -890,24 +890,31 @@ namespace WinSCP
         {
             using (_logger.CreateCallstack())
             {
-                FileVersionInfo version = FileVersionInfo.GetVersionInfo(exePath);
-
-                _logger.WriteLine("Version of {0} is {1}, product {2} version is {3}", exePath, version.FileVersion, version.ProductName, version.ProductVersion);
-
-                if (_session.DisableVersionCheck)
+                if (assemblyVersion == null)
                 {
-                    _logger.WriteLine("Version check disabled (not recommended)");
+                    _logger.WriteLine("Assembly version not known, cannot check version");
                 }
-                else if (assemblyVersion == null)
+                else if (assemblyVersion.ProductVersion == AssemblyConstants.UndefinedProductVersion)
                 {
-                    _logger.WriteLine("Assembly version not known, cannot check version");
+                    _logger.WriteLine("Undefined assembly version, cannot check version");
                 }
-                else if (assemblyVersion.ProductVersion != version.ProductVersion)
+                else
                 {
-                    throw new SessionLocalException(
-                        _session, string.Format(CultureInfo.CurrentCulture,
-                            "The version of {0} ({1}) does not match version of this assembly {2} ({3}).",
-                            exePath, version.ProductVersion, _logger.GetAssemblyFilePath(), assemblyVersion.ProductVersion));
+                    FileVersionInfo version = FileVersionInfo.GetVersionInfo(exePath);
+
+                    _logger.WriteLine("Version of {0} is {1}, product {2} version is {3}", exePath, version.FileVersion, version.ProductName, version.ProductVersion);
+
+                    if (_session.DisableVersionCheckInternal)
+                    {
+                        _logger.WriteLine("Version check disabled (not recommended)");
+                    }
+                    else if (assemblyVersion.ProductVersion != version.ProductVersion)
+                    {
+                        throw new SessionLocalException(
+                            _session, string.Format(CultureInfo.CurrentCulture,
+                                "The version of {0} ({1}) does not match version of this assembly {2} ({3}).",
+                                exePath, version.ProductVersion, _logger.GetAssemblyFilePath(), assemblyVersion.ProductVersion));
+                    }
                 }
             }
         }

+ 5 - 2
dotnet/properties/AssemblyInfo.cs

@@ -22,14 +22,17 @@ using System.Runtime.InteropServices;
 
 [assembly: AssemblyVersion(WinSCP.AssemblyConstants.Version)]
 [assembly: AssemblyFileVersion(WinSCP.AssemblyConstants.Version)]
-[assembly: AssemblyInformationalVersionAttribute(WinSCP.AssemblyConstants.Version)]
+[assembly: AssemblyInformationalVersionAttribute(WinSCP.AssemblyConstants.ProductVersion)]
 
 [assembly: CLSCompliant(true)]
 
 namespace WinSCP
 {
-    internal class AssemblyConstants
+    internal static class AssemblyConstants
     {
+        public const string UndefinedProductVersion = "9.9.9.9";
+
         public const string Version = "1.4.0.0";
+        public const string ProductVersion = "5.10.0.0";
     }
 }