1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

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
This commit is contained in:
Martin Prikryl
2016-12-02 08:49:47 +00:00
parent f9dd330fcd
commit 472980fce2
3 changed files with 27 additions and 33 deletions

View File

@@ -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";

View File

@@ -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)
{
_logger.WriteLine("Version check disabled (not recommended)");
}
else if (assemblyVersion == null)
if (assemblyVersion == null)
{
_logger.WriteLine("Assembly version not known, cannot check version");
}
else if (assemblyVersion.ProductVersion != version.ProductVersion)
else if (assemblyVersion.ProductVersion == AssemblyConstants.UndefinedProductVersion)
{
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));
_logger.WriteLine("Undefined assembly version, cannot check version");
}
else
{
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));
}
}
}
}

View File

@@ -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";
}
}