diff --git a/appveyor.yml b/appveyor.yml index 02f1487..2067927 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,7 @@ version: 1.16.{build}.0 image: Visual Studio 2017 build_script: +- ps: .\build.ps1 -configuration Release_LIB - ps: .\build.ps1 -configuration Release_DLL deploy: - provider: Environment diff --git a/build/Build.cs b/build/Build.cs index 0986df4..60d601f 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,46 +1,49 @@ using System; -using System.Linq; +using System.IO; +using JsonConfig; using Nuke.Common; +using Nuke.Common.BuildServers; using Nuke.Common.Git; using Nuke.Common.ProjectModel; +using Nuke.Common.Tools.GitVersion; using Nuke.Common.Tools.MSBuild; -using static Nuke.Common.EnvironmentInfo; +using Vestris.ResourceLib; using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.IO.PathConstruction; using static Nuke.Common.Tools.MSBuild.MSBuildTasks; -class Build : NukeBuild +internal class Build : NukeBuild { - public static int Main () => Execute(x => x.Compile); + [GitRepository] private readonly GitRepository GitRepository; + [GitVersion] private readonly GitVersion GitVersion; - [Solution] readonly Solution Solution; - [GitRepository] readonly GitRepository GitRepository; + [Solution("ViGEmClient.sln")] private readonly Solution Solution; - AbsolutePath SourceDirectory => RootDirectory / "src"; - AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; + private AbsolutePath SourceDirectory => RootDirectory / "src"; + private AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts"; - Target Clean => _ => _ + private Target Clean => _ => _ .Executes(() => { DeleteDirectories(GlobDirectories(SourceDirectory, "**/bin", "**/obj")); EnsureCleanDirectory(ArtifactsDirectory); }); - Target Restore => _ => _ + private Target Restore => _ => _ .DependsOn(Clean) .Executes(() => { MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Restore")); }); - Target Compile => _ => _ + private Target Compile => _ => _ .DependsOn(Restore) .Executes(() => { MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Rebuild") .SetConfiguration(Configuration) .SetMaxCpuCount(Environment.ProcessorCount) @@ -48,12 +51,26 @@ class Build : NukeBuild .SetTargetPlatform(MSBuildTargetPlatform.x64)); MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Rebuild") .SetConfiguration(Configuration) .SetMaxCpuCount(Environment.ProcessorCount) .SetNodeReuse(IsLocalBuild) .SetTargetPlatform(MSBuildTargetPlatform.x86)); + + if (Configuration.Equals("release_dll", StringComparison.InvariantCultureIgnoreCase)) + { + var version = + new Version(IsLocalBuild ? GitVersion.GetNormalizedFileVersion() : AppVeyor.Instance.BuildVersion); + + StampVersion( + Path.Combine(RootDirectory, @"bin\release\x64\ViGEmClient.dll"), + version); + + StampVersion( + Path.Combine(RootDirectory, @"bin\release\x86\ViGEmClient.dll"), + version); + } }); private Target Pack => _ => _ @@ -61,10 +78,49 @@ class Build : NukeBuild .Executes(() => { MSBuild(s => s - .SetTargetPath(SolutionFile) + .SetTargetPath(Solution) .SetTargets("Restore", "Pack") .SetPackageOutputPath(ArtifactsDirectory) .SetConfiguration(Configuration) .EnableIncludeSymbols()); }); -} + + public static int Main() + { + return Execute(x => x.Compile); + } + + private static void StampVersion(string path, Version version) + { + var versionResource = new VersionResource + { + FileVersion = version.ToString(), + ProductVersion = version.ToString() + }; + + var stringFileInfo = new StringFileInfo(); + versionResource[stringFileInfo.Key] = stringFileInfo; + var stringFileInfoStrings = new StringTable + { + LanguageID = 1033, + CodePage = 1200 + }; + stringFileInfo.Strings.Add(stringFileInfoStrings.Key, stringFileInfoStrings); + stringFileInfoStrings["CompanyName"] = Config.Global.Version.CompanyName; + stringFileInfoStrings["FileDescription"] = Config.Global.Version.FileDescription; + stringFileInfoStrings["FileVersion"] = version.ToString(); + stringFileInfoStrings["InternalName"] = Config.Global.Version.InternalName; + stringFileInfoStrings["LegalCopyright"] = Config.Global.Version.LegalCopyright; + stringFileInfoStrings["OriginalFilename"] = Config.Global.Version.OriginalFilename; + stringFileInfoStrings["ProductName"] = Config.Global.Version.ProductName; + stringFileInfoStrings["ProductVersion"] = version.ToString(); + + var varFileInfo = new VarFileInfo(); + versionResource[varFileInfo.Key] = varFileInfo; + var varFileInfoTranslation = new VarTable("Translation"); + varFileInfo.Vars.Add(varFileInfoTranslation.Key, varFileInfoTranslation); + varFileInfoTranslation[ResourceUtil.USENGLISHLANGID] = 1300; + + versionResource.SaveTo(path); + } +} \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj index 6212d6b..75bc310 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -10,14 +10,21 @@ + + + + + + Never + diff --git a/build/default.json b/build/default.json new file mode 100644 index 0000000..f98e7c9 --- /dev/null +++ b/build/default.json @@ -0,0 +1,10 @@ +{ + "Version": { + "CompanyName": "Benjamin Höglinger-Stelzer", + "FileDescription": "Virtual Gamepad Emulation Framework User-Mode Library", + "InternalName": "ViGEmClient", + "LegalCopyright": "Copyright (C) 2017-2018 Benjamin Hoeglinger-Stelzer All Rights Reserved", + "OriginalFilename": "ViGEmClient", + "ProductName": "Virtual Gamepad Emulation Framework User-Mode Library" + } +} \ No newline at end of file diff --git a/src/ViGEmClient.rc b/src/ViGEmClient.rc deleted file mode 100644 index 3a38bba..0000000 --- a/src/ViGEmClient.rc +++ /dev/null @@ -1,110 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x7L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000904b0" - BEGIN - VALUE "CompanyName", "Benjamin Höglinger-Stelzer" - VALUE "FileDescription", "Virtual Gamepad Emulation User-Mode Library" - VALUE "FileVersion", "1.0.0.0" - VALUE "InternalName", "Virtual Gamepad Emulation User-Mode Library" - VALUE "LegalCopyright", "Copyright (C) Benjamin Höglinger-Stelzer 2017-2018" - VALUE "OriginalFilename", "ViGEmClient.lib" - VALUE "ProductName", "Virtual Gamepad Emulation User-Mode Library" - VALUE "ProductVersion", "1.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x9, 1200 - END -END - -#endif // English resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Austria) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEA) -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // German (Austria) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/src/ViGEmClient.vcxproj b/src/ViGEmClient.vcxproj index d0d158c..7732345 100644 --- a/src/ViGEmClient.vcxproj +++ b/src/ViGEmClient.vcxproj @@ -299,14 +299,10 @@ - - - - diff --git a/src/ViGEmClient.vcxproj.filters b/src/ViGEmClient.vcxproj.filters index 58fac3a..d8eb3a3 100644 --- a/src/ViGEmClient.vcxproj.filters +++ b/src/ViGEmClient.vcxproj.filters @@ -21,9 +21,6 @@ - - Header Files - Header Files\ViGEm @@ -33,8 +30,8 @@ Header Files\ViGEm - - Header Files\ViGEm\km + + Header Files @@ -42,9 +39,4 @@ Source Files - - - Resource Files - - \ No newline at end of file diff --git a/src/resource.h b/src/resource.h deleted file mode 100644 index ab53b9b..0000000 --- a/src/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by ViGEmClient.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif