From 5c7b3139e29a450454eadbf686e1217894a4e341 Mon Sep 17 00:00:00 2001 From: acoates-ms <30809111+acoates-ms@users.noreply.github.com> Date: Fri, 7 Jun 2019 16:47:46 -0700 Subject: [PATCH] Add basic version info to win32 dll. (#2592) --- .ado/updateVersion.js | 69 ++++++++++++++----- .../React.Windows.Desktop.DLL.vcxproj | 3 + .../React.Windows.Desktop.DLL.vcxproj.filters | 3 + vnext/Desktop.DLL/Version.rc | 48 +++++++++++++ vnext/package.json | 2 +- vnext/yarn.lock | 27 +++++--- 6 files changed, 125 insertions(+), 27 deletions(-) create mode 100644 vnext/Desktop.DLL/Version.rc diff --git a/.ado/updateVersion.js b/.ado/updateVersion.js index 17ac3abd43e..ffb86358e9d 100644 --- a/.ado/updateVersion.js +++ b/.ado/updateVersion.js @@ -1,5 +1,5 @@ // @ts-check -// Used to update the package version +// Used to update the package version const fs = require("fs"); const path = require("path"); @@ -19,17 +19,26 @@ function exec(command) { } function updateVersion() { - const publishBranchName = process.env.BUILD_SOURCEBRANCH.match(/refs\/heads\/(.*)/)[1]; + const publishBranchName = process.env.BUILD_SOURCEBRANCH.match( + /refs\/heads\/(.*)/ + )[1]; // Set env variable to allow npm publish task to publish to correct tag - console.log(`##vso[task.setvariable variable=npmTag]${publishBranchName === 'master' ? 'vnext' : publishBranchName}`); + console.log( + `##vso[task.setvariable variable=npmTag]${ + publishBranchName === "master" ? "vnext" : publishBranchName + }` + ); console.log(`Target branch to publish to: ${publishBranchName}`); const tempPublishBranch = `auto-update-version-publish-temp-${Date.now()}`; - console.log(`Using ${`(.*-microsoft)(-${publishBranchName})?\\.([0-9]*)`} to match version`); - const branchVersionSuffix = (publishBranchName.match(/(fb.*merge)|(fabric)/) ? `-${publishBranchName}` : ''); - + console.log( + `Using ${`(.*-microsoft)(-${publishBranchName})?\\.([0-9]*)`} to match version` + ); + const branchVersionSuffix = publishBranchName.match(/(fb.*merge)|(fabric)/) + ? `-${publishBranchName}` + : ""; exec(`npm install -g yarn`); @@ -37,18 +46,24 @@ function updateVersion() { exec(`git fetch origin ${publishBranchName}`); exec(`git checkout ${publishBranchName} --force`); exec(`git reset --hard origin/${publishBranchName}`); - + exec(`git checkout -b ${tempPublishBranch}`); const pkgJsonPath = path.resolve(__dirname, "../vnext/package.json"); let pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8")); let releaseVersion = pkgJson.version; - - const versionStringRegEx = new RegExp(`(.*-vnext)(-${publishBranchName})?\\.([0-9]*)`); + + const versionStringRegEx = new RegExp( + `(.*-vnext)(-${publishBranchName})?\\.([0-9]*)` + ); const versionGroups = versionStringRegEx.exec(releaseVersion); if (versionGroups) { - releaseVersion = versionGroups[1] + branchVersionSuffix + '.' + (parseInt(versionGroups[3]) + 1); + releaseVersion = + versionGroups[1] + + branchVersionSuffix + + "." + + (parseInt(versionGroups[3]) + 1); } else { if (releaseVersion.indexOf("-") === -1) { releaseVersion = releaseVersion + `-vnext${branchVersionSuffix}.0`; @@ -62,13 +77,37 @@ function updateVersion() { fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2)); console.log(`Updating package.json to version ${releaseVersion}`); + const win32VersionRcPath = path.resolve( + __dirname, + "../vnext/Desktop.DLL/Version.rc" + ); + + let versionRC = fs.readFileSync(win32VersionRcPath).toString(); + versionRC = versionRC.replace( + /#define VER_FILEVERSION_STR\s+"[^"]+"/, + `#define VER_FILEVERSION_STR "${releaseVersion}"` + ); + versionRC = versionRC.replace( + /#define VER_FILEVERSION\s+.+/, + `#define VER_FILEVERSION ${releaseVersion.split(".")[0]},${ + releaseVersion.split(".")[1] + },${releaseVersion.split(".")[2].split("-")[0]},${parseInt( + versionGroups[3] + ) + 1}` + ); + fs.writeFileSync(win32VersionRcPath, versionRC); + process.chdir(path.resolve(__dirname, "../vnext")); - exec(`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd install`); + exec( + `${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd install` + ); exec(`${process.env.APPDATA}\\npm\\node_modules\\yarn\\bin\\yarn.cmd build`); - const tagName = 'vnext-' + releaseVersion; + const tagName = "vnext-" + releaseVersion; exec(`git add ${pkgJsonPath}`); + exec(`git add ${win32VersionRcPath}`); + exec(`git commit -m "Applying package update to ${releaseVersion}`); exec(`git tag ${tagName}`); exec(`git push origin HEAD:${tempPublishBranch} --follow-tags --verbose`); @@ -77,11 +116,9 @@ function updateVersion() { exec(`git checkout ${publishBranchName}`); exec(`git pull origin ${publishBranchName}`); exec(`git merge ${tempPublishBranch} --no-edit`); - exec( - `git push origin HEAD:${publishBranchName} --follow-tags --verbose` - ); + exec(`git push origin HEAD:${publishBranchName} --follow-tags --verbose`); exec(`git branch -d ${tempPublishBranch}`); exec(`git push origin --delete -d ${tempPublishBranch}`); } -updateVersion(); \ No newline at end of file +updateVersion(); diff --git a/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj b/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj index ba71fea2de5..8f91b57c4f8 100644 --- a/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj +++ b/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj @@ -141,6 +141,9 @@ {95048601-C3DC-475F-ADF8-7C0C764C10D5} + + + diff --git a/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj.filters b/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj.filters index 70da2073bd7..6ad60aee3c6 100644 --- a/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj.filters +++ b/vnext/Desktop.DLL/React.Windows.Desktop.DLL.vcxproj.filters @@ -11,4 +11,7 @@ + + + \ No newline at end of file diff --git a/vnext/Desktop.DLL/Version.rc b/vnext/Desktop.DLL/Version.rc new file mode 100644 index 00000000000..10348dcb7f7 --- /dev/null +++ b/vnext/Desktop.DLL/Version.rc @@ -0,0 +1,48 @@ +#include + +#define VER_FILEVERSION 3,10,349,0 +#define VER_FILEVERSION_STR "3.10.349.0\0" + +#ifndef DEBUG +#define VER_DEBUG 0 +#else +#define VER_DEBUG VS_FF_DEBUG +#endif + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_FILEVERSION +FILEFLAGSMASK (VS_FF_DEBUG) +FILEFLAGS(VER_DEBUG) +FILEOS VOS__WINDOWS32 +FILETYPE VFT_DLL +FILESUBTYPE VFT2_UNKNOWN +BEGIN +BLOCK "StringFileInfo" +BEGIN +BLOCK "040904E4" +BEGIN +VALUE "CompanyName", "Microsoft" +VALUE "FileDescription", "React-Native-Windows" +VALUE "FileVersion", VER_FILEVERSION_STR +VALUE "InternalName", "react-native-win32.dll" +VALUE "LegalCopyright", "(c) Microsoft Corporation. All rights reserved." +VALUE "OriginalFilename", "react-native-win32.dll" +VALUE "ProductName", "React-Native-Windows" +VALUE "ProductVersion", VER_FILEVERSION_STR +END +END + +BLOCK "VarFileInfo" +BEGIN +/* The following line should only be modified for localized versions. */ +/* It consists of any number of WORD,WORD pairs, with each pair */ +/* describing a language,codepage combination supported by the file. */ +/* */ +/* For example, a file might have values "0x409,1252" indicating that it */ +/* supports English language (0x409) in the Windows ANSI codepage (1252). */ + +VALUE "Translation", 0x409, 1252 + +END +END diff --git a/vnext/package.json b/vnext/package.json index 5eabf000781..5b8f5d46c0a 100644 --- a/vnext/package.json +++ b/vnext/package.json @@ -63,7 +63,7 @@ "react": "16.6.3", "tslint": "^5.11.0", "tslint-microsoft-contrib": "^5.0.1", - "tslint-react": "^3.5.0", + "tslint-react": "^4", "typescript": "3.5.1", "react-native": "0.58.6-microsoft.60" }, diff --git a/vnext/yarn.lock b/vnext/yarn.lock index 7d90dcfbde0..7ccb6fb9844 100644 --- a/vnext/yarn.lock +++ b/vnext/yarn.lock @@ -4939,12 +4939,12 @@ tslint-microsoft-contrib@^5.0.1: dependencies: tsutils "^2.27.2 <2.29.0" -tslint-react@^3.5.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-3.6.0.tgz#7f462c95c4a0afaae82507f06517ff02942196a1" - integrity sha512-AIv1QcsSnj7e9pFir6cJ6vIncTqxfqeFF3Lzh8SuuBljueYzEAtByuB6zMaD27BL0xhMEqsZ9s5eHuCONydjBw== +tslint-react@^4: + version "4.0.0" + resolved "https://registry.yarnpkg.com/tslint-react/-/tslint-react-4.0.0.tgz#b4bb4c01c32448cb14d23f143a2f5e4989bb961e" + integrity sha512-9fNE0fm9zNDx1+b6hgy8rgDN2WsQLRiIrn3+fbqm0tazBVF6jiaCFAITxmU+WSFWYE03Xhp1joCircXOe1WVAQ== dependencies: - tsutils "^2.13.1" + tsutils "^3.9.1" tslint@^5.11.0: version "5.15.0" @@ -4965,17 +4965,24 @@ tslint@^5.11.0: tslib "^1.8.0" tsutils "^2.29.0" -tsutils@^2.13.1, tsutils@^2.29.0: +"tsutils@^2.27.2 <2.29.0": + version "2.28.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.28.0.tgz#6bd71e160828f9d019b6f4e844742228f85169a1" + integrity sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA== + dependencies: + tslib "^1.8.1" + +tsutils@^2.29.0: version "2.29.0" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA== dependencies: tslib "^1.8.1" -"tsutils@^2.27.2 <2.29.0": - version "2.28.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.28.0.tgz#6bd71e160828f9d019b6f4e844742228f85169a1" - integrity sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA== +tsutils@^3.9.1: + version "3.14.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.14.0.tgz#bf8d5a7bae5369331fa0f2b0a5a10bd7f7396c77" + integrity sha512-SmzGbB0l+8I0QwsPgjooFRaRvHLBLNYM8SeQ0k6rtNDru5sCGeLJcZdwilNndN+GysuFjF5EIYgN8GfFG6UeUw== dependencies: tslib "^1.8.1"