From 0acc9b27958375b0fae27ec292b6e18aae5a2a19 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Fri, 19 Jun 2015 10:24:14 -0700 Subject: [PATCH 1/2] win: fix custom actions on Visual Studio != 2013 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a port of joyent/node@16bcd68dc5f449c331499ced22aa626dbb2cdefc . Original commit message: The original change that added support for running custom actions during the install process (joyent/node@e7c84f82c730bddb7450dc56065aab11b93ffd30) assumed that Visual Studio 2013 is used to generate the installer file. However, that is not always the case, and older versions of Visual Studio should allow users to generate Windows installer files. This change makes the custom actions visual studio project use the visual studio version that is found by vcbuild.bat. Reviewed-By: João Reis PR-URL: https://github.com/joyent/node/pull/25569 PR-URL: https://github.com/nodejs/node/pull/2365 Reviewed-By: Alexis Campailla --- tools/msvs/msi/custom_actions.vcxproj | 28 +++++++++++++-------------- vcbuild.bat | 28 ++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/tools/msvs/msi/custom_actions.vcxproj b/tools/msvs/msi/custom_actions.vcxproj index e014a6981f5fc9..ae82905cd4b1f4 100644 --- a/tools/msvs/msi/custom_actions.vcxproj +++ b/tools/msvs/msi/custom_actions.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -27,24 +27,24 @@ DynamicLibrary - v120 + $(PlatformToolset) Unicode true DynamicLibrary - v120 + $(PlatformToolset) Unicode true DynamicLibrary - v120 + $(PlatformToolset) Unicode DynamicLibrary - v120 + $(PlatformToolset) Unicode @@ -81,7 +81,7 @@ Disabled - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -91,7 +91,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x86;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x86;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -100,7 +100,7 @@ Disabled - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebug @@ -110,7 +110,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x64;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x64;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -120,7 +120,7 @@ MaxSpeed true - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreaded true @@ -134,7 +134,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x86;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x86;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -146,7 +146,7 @@ MaxSpeed true - $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\inc;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) MultiThreaded true @@ -160,7 +160,7 @@ msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) - $(WIX)sdk\VS2013\lib\x64;%(AdditionalLibraryDirectories) + $(WIX)sdk\VS$(GypMsvsVersion)\lib\x64;%(AdditionalLibraryDirectories) custom_actions.def true Windows @@ -178,4 +178,4 @@ - \ No newline at end of file + diff --git a/vcbuild.bat b/vcbuild.bat index 9eaa34f0a070bd..1073a3e5886eea 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -103,32 +103,58 @@ call :getnodeversion || exit /b 1 @rem Set environment for msbuild @rem Look for Visual Studio 2015 +echo Looking for Visual Studio 2015 if not defined VS140COMNTOOLS goto vc-set-2013 if not exist "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" goto vc-set-2013 +echo Found Visual Studio 2015 +if defined msi ( + echo Looking for WiX installation for Visual Studio 2015... + if not exist "%WIX%\SDK\VS2015" ( + echo Failed to find WiX install for Visual Studio 2015 + echo VS2015 support for WiX is only present starting at version 3.10 + goto vc-set-2013 + ) +) if "%VCVARS_VER%" NEQ "140" ( call "%VS140COMNTOOLS%\..\..\vc\vcvarsall.bat" SET VCVARS_VER=140 ) if not defined VCINSTALLDIR goto vc-set-2013 set GYP_MSVS_VERSION=2015 +set PLATFORM_TOOLSET=v140 goto msbuild-found :vc-set-2013 @rem Look for Visual Studio 2013 +echo Looking for Visual Studio 2013 if not defined VS120COMNTOOLS goto msbuild-not-found if not exist "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" goto msbuild-not-found +echo Found Visual Studio 2013 +if defined msi ( + echo Looking for WiX installation for Visual Studio 2013... + if not exist "%WIX%\SDK\VS2013" ( + echo Failed to find WiX install for Visual Studio 2013 + echo VS2013 support for WiX is only present starting at version 3.8 + goto vc-set-2012 + ) +) if "%VCVARS_VER%" NEQ "120" ( call "%VS120COMNTOOLS%\..\..\vc\vcvarsall.bat" SET VCVARS_VER=120 ) if not defined VCINSTALLDIR goto msbuild-not-found set GYP_MSVS_VERSION=2013 +set PLATFORM_TOOLSET=v120 goto msbuild-found :msbuild-not-found echo Failed to find Visual Studio installation. goto exit +:wix-not-found +echo Build skipped. To generate installer, you need to install Wix. +goto run + :msbuild-found :project-gen @@ -170,7 +196,7 @@ if not defined msi goto run :msibuild echo Building node-v%FULLVERSION%-%target_arch%.msi -msbuild "%~dp0tools\msvs\msi\nodemsi.sln" /m /t:Clean,Build /p:Configuration=%config% /p:Platform=%target_arch% /p:NodeVersion=%NODE_VERSION% /p:FullVersion=%FULLVERSION% /p:DistTypeDir=%DISTTYPEDIR% %noetw_msi_arg% %noperfctr_msi_arg% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo +msbuild "%~dp0tools\msvs\msi\nodemsi.sln" /m /t:Clean,Build /p:PlatformToolset=%PLATFORM_TOOLSET% /p:GypMsvsVersion=%GYP_MSVS_VERSION% /p:Configuration=%config% /p:Platform=%target_arch% /p:NodeVersion=%NODE_VERSION% /p:FullVersion=%FULLVERSION% /p:DistTypeDir=%DISTTYPEDIR% %noetw_msi_arg% %noperfctr_msi_arg% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo if errorlevel 1 goto exit if defined nosign goto upload From bce1aea4253b124cbeafb913395ff5db3678d225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Tue, 21 Jul 2015 21:39:15 +0100 Subject: [PATCH 2/2] win: fix custom actions for WiX older than 3.9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a port of joyent/node@e192f61514cd1500de895cb10128d412f842d7d0 . Original commit message: Older WiX versions included a header with extern "C" declaration, hence the custom action source must be C++. Reviewed-By: João Reis PR-URL: https://github.com/joyent/node/pull/25569 PR-URL: https://github.com/nodejs/node/pull/2365 Reviewed-By: Alexis Campailla --- tools/msvs/msi/{custom_actions.c => custom_actions.cc} | 4 ++-- tools/msvs/msi/custom_actions.vcxproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename tools/msvs/msi/{custom_actions.c => custom_actions.cc} (83%) diff --git a/tools/msvs/msi/custom_actions.c b/tools/msvs/msi/custom_actions.cc similarity index 83% rename from tools/msvs/msi/custom_actions.c rename to tools/msvs/msi/custom_actions.cc index 5e7d617f387915..9a23d557476004 100644 --- a/tools/msvs/msi/custom_actions.c +++ b/tools/msvs/msi/custom_actions.cc @@ -6,7 +6,7 @@ #include -UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { +extern "C" UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { HRESULT hr = S_OK; UINT er = ERROR_SUCCESS; @@ -27,7 +27,7 @@ UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { } -BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason, VOID* dummy) { +extern "C" BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason, VOID* dummy) { switch (ulReason) { case DLL_PROCESS_ATTACH: WcaGlobalInitialize(hInst); diff --git a/tools/msvs/msi/custom_actions.vcxproj b/tools/msvs/msi/custom_actions.vcxproj index ae82905cd4b1f4..3716f07ff6de3d 100644 --- a/tools/msvs/msi/custom_actions.vcxproj +++ b/tools/msvs/msi/custom_actions.vcxproj @@ -169,7 +169,7 @@ - +