Skip to content

Commit

Permalink
Fixed version.host and version.buildDate.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeStrout committed Jan 13, 2022
1 parent e9406c5 commit 911eec4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions M1/M1API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public static void Init(Shell shell) {

if (shell.bot == null) HostInfo.name = "Farmtronics Home Computer";
else HostInfo.name = "Farmtronics Bot";
HostInfo.version = 0.1;
HostInfo.info = "http://miniscript.org/"; // to-do: put our mod URL here
HostInfo.version = 1.01;
HostInfo.info = "https://github.com/JoeStrout/Farmtronics/";

Intrinsic f;

Expand Down
21 changes: 14 additions & 7 deletions M1/Miniscript/MiniscriptIntrinsics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,13 +1445,20 @@ public static void InitIfNeeded() {
d["miniscript"] = new ValString("1.5.1");

// Getting the build date is annoyingly hard in C#.
// This will work if the assembly.cs file uses the version format: 1.0.*
DateTime buildDate;
System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
buildDate = new DateTime(2000, 1, 1);
buildDate = buildDate.AddDays(version.Build);
buildDate = buildDate.AddSeconds(version.Revision * 2);
d["buildDate"] = new ValString(buildDate.ToString("yyyy-MM-dd"));
// The following requires that you paste a line such as:
// <Copyright>Copyright © $([System.DateTime]::UtcNow.Year) Your Name ($([System.DateTime]::UtcNow.ToString("s")))</Copyright>
// ...into your .csproj file, inside the first PropertyGroup block.
string buildDate = "2000-01-01";
// For MOST contexts you would just do this:
//var vers = System.Diagnostics.FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
// But for a Stardew mod, we must hack this file and do this:
var vers = System.Diagnostics.FileVersionInfo.GetVersionInfo(System.IO.Path.Combine(Farmtronics.ModEntry.instance.Helper.DirectoryPath, "Farmtronics.dll"));
if (!string.IsNullOrEmpty(vers.LegalCopyright)) {
var re = new System.Text.RegularExpressions.Regex(@"(20\d\d-\d\d-\d\d)");
var match = re.Match(vers.LegalCopyright);
if (match.Success) buildDate = match.Value;
}
d["buildDate"] = new ValString(buildDate);

d["host"] = new ValNumber(HostInfo.version);
d["hostName"] = new ValString(HostInfo.name);
Expand Down

0 comments on commit 911eec4

Please sign in to comment.