wix project to create msi installer for windows
authorTomasz Janczuk <tomasz@janczuk.org>
Wed, 14 Sep 2011 21:51:49 +0000 (14:51 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Tue, 11 Oct 2011 17:29:03 +0000 (10:29 -0700)
Fixes #1706.

.gitignore
tools/msi/LICENSE.rtf [new file with mode: 0644]
tools/msi/getnodeversion.py [new file with mode: 0644]
tools/msi/nodemsi.sln [new file with mode: 0644]
tools/msi/nodemsi.wixproj [new file with mode: 0644]
tools/msi/product.wxs [new file with mode: 0644]
vcbuild.bat

index e77d5df..68b5843 100644 (file)
@@ -18,6 +18,7 @@ node_g
 Debug/
 Release/
 *.sln
+!nodemsi.sln
 *.suo
 *.vcproj
 *.vcxproj
diff --git a/tools/msi/LICENSE.rtf b/tools/msi/LICENSE.rtf
new file mode 100644 (file)
index 0000000..8afd327
Binary files /dev/null and b/tools/msi/LICENSE.rtf differ
diff --git a/tools/msi/getnodeversion.py b/tools/msi/getnodeversion.py
new file mode 100644 (file)
index 0000000..a9a5274
--- /dev/null
@@ -0,0 +1,9 @@
+import sys,re; 
+for line in sys.stdin:
+  if re.match('#define NODE_MAJOR_VERSION', line):
+    major = line.split()[2]
+  if re.match('#define NODE_MINOR_VERSION', line):
+    minor = line.split()[2]
+  if re.match('#define NODE_PATCH_VERSION', line):
+    patch = line.split()[2]
+print '{0:s}.{1:s}.{2:s}.0'.format(major, minor, patch)
diff --git a/tools/msi/nodemsi.sln b/tools/msi/nodemsi.sln
new file mode 100644 (file)
index 0000000..1392bb2
--- /dev/null
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "nodemsi", "nodemsi.wixproj", "{1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|x86 = Debug|x86
+               Release|x86 = Release|x86
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|x86.ActiveCfg = Debug|x86
+               {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Debug|x86.Build.0 = Debug|x86
+               {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x86.ActiveCfg = Release|x86
+               {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x86.Build.0 = Release|x86
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/tools/msi/nodemsi.wixproj b/tools/msi/nodemsi.wixproj
new file mode 100644 (file)
index 0000000..4253624
--- /dev/null
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+    <ProductVersion>3.5</ProductVersion>
+    <ProjectGuid>{1d808ff0-b5a9-4be9-859d-b334b6f48be2}</ProjectGuid>
+    <SchemaVersion>2.0</SchemaVersion>
+    <OutputName>node</OutputName>
+    <OutputType>Package</OutputType>
+    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
+    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
+    <NodeVersion Condition=" '$(NodeVersion)' == '' ">0.0.0.0</NodeVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+    <OutputPath>..\..\$(Configuration)\</OutputPath>
+    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
+    <DefineConstants>Debug;ProductVersion=$(NodeVersion)</DefineConstants>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+    <OutputPath>..\..\$(Configuration)\</OutputPath>
+    <IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
+    <DefineConstants>Debug;ProductVersion=$(NodeVersion)</DefineConstants>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="product.wxs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="LICENSE.rtf" />
+  </ItemGroup>
+  <ItemGroup>
+    <WixExtension Include="WixUIExtension">
+      <HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
+      <Name>WixUIExtension</Name>
+    </WixExtension>
+  </ItemGroup>
+  <Import Project="$(WixTargetsPath)" />
+  <!--
+       To modify your build process, add your task inside one of the targets below and uncomment it.
+       Other similar extension points exist, see Wix.targets.
+       <Target Name="BeforeBuild">
+       </Target>
+       <Target Name="AfterBuild">
+       </Target>
+       -->
+</Project>
\ No newline at end of file
diff --git a/tools/msi/product.wxs b/tools/msi/product.wxs
new file mode 100644 (file)
index 0000000..89a6129
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+
+  <?define sourcedir="$(var.ProjectDir)..\..\$(var.Configuration)\" ?>
+
+  <Product Id="cc6c176e-e26c-48ec-8970-f58bd1d046cf"
+           Name="node.js"
+           Language="1033"
+           Version="$(var.ProductVersion)"
+           Manufacturer="Joyent, Inc"
+           UpgradeCode="1d60944c-b9ce-4a71-a7c0-0384eb884baa">
+
+    <Package InstallerVersion="200" Compressed="yes" Platform="x86" />
+
+    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
+    
+    <Directory Id="TARGETDIR" Name="SourceDir">
+      <Directory Id="ProgramFilesFolder">
+        <Directory Id="NodeRoot" Name="nodejs">
+          <Component Id="nodeexe" Guid="AEC0F08E-89B3-4C35-A286-8DB8598597F2">
+            <File Id="filenodeexe" KeyPath="yes" Source="$(var.sourcedir)\node.exe" />
+          </Component>
+          <?if $(var.Configuration) = Debug ?>
+          <Component Id="nodepdb" Guid="BEC0F08E-89B3-4C35-A286-8DB8598597F2">
+            <File Id="filenodepdb" KeyPath="yes" Source="$(var.sourcedir)\node.pdb" />
+          </Component>
+          <?endif?>
+          <Component Id="license" Guid="CEC0F08E-89B3-4C35-A286-8DB8598597F2">
+            <File Id="filelicense" KeyPath="yes" Source="$(var.sourcedir)\..\LICENSE" />
+          </Component>
+        </Directory>
+      </Directory>
+    </Directory>
+
+    <ComponentGroup Id="allfiles">
+      <ComponentRef Id="nodeexe"/>
+      <?if $(var.Configuration) = Debug ?>
+      <ComponentRef Id="nodepdb"/>
+      <?endif?>
+      <ComponentRef Id="license"/>
+    </ComponentGroup>
+
+    <Feature Id="nodejs" Title="node.js engine" Level="1" Description="evented I/O for V8 javascript">
+      <ComponentGroupRef Id="allfiles" />
+      <ComponentGroupRef Id="Product.Generated" />
+    </Feature>
+
+    <WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\license.rtf" />
+    <UIRef Id="WixUI_Minimal" />
+
+  </Product>
+
+</Wix>
index 90e89d9..fb56574 100644 (file)
@@ -18,6 +18,7 @@ set noprojgen=
 set nobuild=
 set test=
 set test_args=
+set msi=
 
 :next-arg
 if "%1"=="" goto args-done
@@ -33,6 +34,7 @@ if /i "%1"=="test-simple"  set test=test-simple&goto arg-ok
 if /i "%1"=="test-message" set test=test-message&goto arg-ok
 if /i "%1"=="test-all"     set test=test-all&goto arg-ok
 if /i "%1"=="test"         set test=test&goto arg-ok
+if /i "%1"=="msi"          set msi=1&goto arg-ok
 :arg-ok
 shift
 goto next-arg
@@ -51,7 +53,7 @@ echo Project files generated.
 
 :msbuild
 @rem Skip project generation if requested.
-if defined nobuild goto run
+if defined nobuild goto msi
 
 @rem Bail out early if not running in VS build env.
 if defined VCINSTALLDIR goto msbuild-found
@@ -70,6 +72,15 @@ goto run
 msbuild node.sln /t:%target% /p:Configuration=%config% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
 if errorlevel 1 goto exit
 
+:msi
+@rem Skip msi generation if not requested
+if not defined msi goto run
+python "%~dp0tools\msi\getnodeversion.py" < "%~dp0src\node_version.h" > "%temp%\node_version.txt"
+if not errorlevel 0 echo Cannot determine current version of node.js & goto exit
+for /F "tokens=*" %%i in (%temp%\node_version.txt) do set NODE_VERSION=%%i
+msbuild "%~dp0tools\msi\nodemsi.sln" /t:Clean,Build /p:Configuration=%config% /p:NodeVersion=%NODE_VERSION% /clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal /nologo
+if errorlevel 1 goto exit
+
 :run
 @rem Run tests if requested.
 if "%test%"=="" goto exit
@@ -94,9 +105,10 @@ echo Failed to create vc project files.
 goto exit
 
 :help
-echo vcbuild.bat [debug/release] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [nobuild]
+echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [nobuild]
 echo Examples:
 echo   vcbuild.bat                : builds debug build
+echo   vcbuild.bat release msi    : builds release build and MSI installer package
 echo   vcbuild.bat test           : builds debug build and runs tests
 echo   vcbuild.bat release test-uv: builds release build and runs --libuv tests
 goto exit