Use SharedInfo + Add ConfigGenerator version check

This commit is contained in:
JustArchi
2016-06-27 02:07:27 +02:00
parent d68bb01174
commit 951d58161f
9 changed files with 73 additions and 12 deletions

View File

@@ -49,6 +49,9 @@
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\ArchiSteamFarm\SharedInfo.cs">
<Link>SharedInfo.cs</Link>
</Compile>
<Compile Include="ASFConfig.cs" />
<Compile Include="BotConfig.cs" />
<Compile Include="DialogBox.cs" />

View File

@@ -29,6 +29,7 @@ using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using ArchiSteamFarm;
namespace ConfigGenerator {
internal sealed partial class MainForm : Form {
@@ -196,7 +197,7 @@ namespace ConfigGenerator {
args.Cancel = true;
Tutorial.OnAction(Tutorial.EPhase.Help);
Process.Start("https://github.com/JustArchi/ArchiSteamFarm/wiki/Configuration");
Process.Start("https://github.com/" + SharedInfo.GithubRepo + "/wiki/Configuration");
Tutorial.OnAction(Tutorial.EPhase.HelpFinished);
}
}

View File

@@ -23,10 +23,12 @@
*/
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using ArchiSteamFarm;
namespace ConfigGenerator {
internal static class Program {
@@ -35,8 +37,10 @@ namespace ConfigGenerator {
internal const string GlobalConfigFile = ASF + ".json";
private const string ASFDirectory = "ArchiSteamFarm";
private const string ASFExecutableFile = ASF + ".exe";
private static readonly string ExecutableDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
private static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version;
/// <summary>
/// The main entry point for the application.
@@ -75,11 +79,30 @@ namespace ConfigGenerator {
}
}
if (Directory.Exists(ConfigDirectory)) {
if (!Directory.Exists(ConfigDirectory)) {
Logging.LogGenericErrorWithoutStacktrace("Config directory could not be found!");
Environment.Exit(1);
}
if (!File.Exists(ASFExecutableFile)) {
return;
}
Logging.LogGenericErrorWithoutStacktrace("Config directory could not be found!");
FileVersionInfo asfVersionInfo = FileVersionInfo.GetVersionInfo(ASFExecutableFile);
Version asfVersion = new Version(asfVersionInfo.ProductVersion);
if (Version == asfVersion) {
return;
}
Logging.LogGenericErrorWithoutStacktrace(
"Version of ASF and ConfigGenerator doesn't match!" + Environment.NewLine +
"ASF version: " + asfVersion + " | ConfigGenerator version: " + Version + Environment.NewLine +
Environment.NewLine +
"Please use ConfigGenerator from the same ASF release, I'll redirect you to appropriate ASF release..."
);
Process.Start("https://github.com/" + SharedInfo.GithubRepo + "/releases/tag/" + asfVersion);
Environment.Exit(1);
}

View File

@@ -1,5 +1,6 @@
using System.Reflection;
using System.Runtime.InteropServices;
using ArchiSteamFarm;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
@@ -9,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConfigGenerator")]
[assembly: AssemblyCopyright("Copyright © ArchiSteamFarm 2015-2016")]
[assembly: AssemblyCopyright(SharedInfo.Copyright)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -31,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion(SharedInfo.Version)]
[assembly: AssemblyFileVersion(SharedInfo.Version)]