Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit 7cf4cf7

Browse files
authored
Merge pull request #6 from robmen/wix311-template-fixes
Fix WiX v3.11 templates
2 parents 7d35269 + 549d8d6 commit 7cf4cf7

34 files changed

+311
-39
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "stdafx.h"
2+
3+
4+
UINT __stdcall CustomAction1(
5+
MSIHANDLE hInstall
6+
)
7+
{
8+
HRESULT hr = S_OK;
9+
UINT er = ERROR_SUCCESS;
10+
11+
hr = WcaInitialize(hInstall, "CustomAction1");
12+
ExitOnFailure(hr, "Failed to initialize");
13+
14+
WcaLog(LOGMSG_STANDARD, "Initialized.");
15+
16+
// TODO: Add your custom action code here.
17+
18+
19+
LExit:
20+
er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
21+
return WcaFinalize(er);
22+
}
23+
24+
25+
// DllMain - Initialize and cleanup WiX custom action utils.
26+
extern "C" BOOL WINAPI DllMain(
27+
__in HINSTANCE hInst,
28+
__in ULONG ulReason,
29+
__in LPVOID
30+
)
31+
{
32+
switch(ulReason)
33+
{
34+
case DLL_PROCESS_ATTACH:
35+
WcaGlobalInitialize(hInst);
36+
break;
37+
38+
case DLL_PROCESS_DETACH:
39+
WcaGlobalFinalize();
40+
break;
41+
}
42+
43+
return TRUE;
44+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
LIBRARY "$projectname$"
2+
3+
EXPORTS
4+
CustomAction1
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
</ItemGroup>
13+
14+
<PropertyGroup Label="Globals">
15+
<ProjectGuid>{$guid1$}</ProjectGuid>
16+
<Keyword>Win32Proj</Keyword>
17+
<RootNamespace>$safeprojectname$</RootNamespace>
18+
</PropertyGroup>
19+
20+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21+
22+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
23+
<ConfigurationType>DynamicLibrary</ConfigurationType>
24+
<CharacterSet>Unicode</CharacterSet>
25+
</PropertyGroup>
26+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
27+
<ConfigurationType>DynamicLibrary</ConfigurationType>
28+
<CharacterSet>Unicode</CharacterSet>
29+
<WholeProgramOptimization>true</WholeProgramOptimization>
30+
</PropertyGroup>
31+
32+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
33+
34+
<ImportGroup Label="ExtensionSettings">
35+
</ImportGroup>
36+
37+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
38+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
39+
</ImportGroup>
40+
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
41+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
42+
</ImportGroup>
43+
44+
<PropertyGroup Label="UserMacros" />
45+
46+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
47+
<OutDir>bin\$(Configuration)\</OutDir>
48+
<IntDir>obj\$(Configuration)\</IntDir>
49+
<LinkIncremental>true</LinkIncremental>
50+
</PropertyGroup>
51+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
52+
<OutDir>bin\$(Configuration)\</OutDir>
53+
<IntDir>obj\$(Configuration)\</IntDir>
54+
<LinkIncremental>false</LinkIncremental>
55+
</PropertyGroup>
56+
57+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
58+
<ClCompile>
59+
<Optimization>Disabled</Optimization>
60+
<AdditionalIncludeDirectories>$(WIX)sdk\$(WixPlatformToolset)\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
61+
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CUSTOMACTIONTEST_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
62+
<MinimalRebuild>true</MinimalRebuild>
63+
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
64+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
65+
<PrecompiledHeader>Use</PrecompiledHeader>
66+
<WarningLevel>Level3</WarningLevel>
67+
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
68+
</ClCompile>
69+
<Link>
70+
<AdditionalDependencies>msi.lib;dutil.lib;wcautil.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
71+
<AdditionalLibraryDirectories>$(WIX)sdk\$(WixPlatformToolset)\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
72+
<ModuleDefinitionFile>CustomAction.def</ModuleDefinitionFile>
73+
<GenerateDebugInformation>true</GenerateDebugInformation>
74+
<SubSystem>Windows</SubSystem>
75+
<TargetMachine>MachineX86</TargetMachine>
76+
</Link>
77+
</ItemDefinitionGroup>
78+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79+
<ClCompile>
80+
<Optimization>MaxSpeed</Optimization>
81+
<IntrinsicFunctions>true</IntrinsicFunctions>
82+
<AdditionalIncludeDirectories>$(WIX)sdk\$(WixPlatformToolset)\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
83+
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CUSTOMACTIONTEST_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
84+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
85+
<FunctionLevelLinking>true</FunctionLevelLinking>
86+
<PrecompiledHeader>Use</PrecompiledHeader>
87+
<WarningLevel>Level3</WarningLevel>
88+
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
89+
</ClCompile>
90+
<Link>
91+
<AdditionalDependencies>msi.lib;dutil.lib;wcautil.lib;Version.lib;%(AdditionalDependencies)</AdditionalDependencies>
92+
<AdditionalLibraryDirectories>$(WIX)sdk\$(WixPlatformToolset)\lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
93+
<ModuleDefinitionFile>CustomAction.def</ModuleDefinitionFile>
94+
<GenerateDebugInformation>true</GenerateDebugInformation>
95+
<SubSystem>Windows</SubSystem>
96+
<OptimizeReferences>true</OptimizeReferences>
97+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
98+
<TargetMachine>MachineX86</TargetMachine>
99+
</Link>
100+
</ItemDefinitionGroup>
101+
102+
<ItemGroup>
103+
<ClCompile Include="CustomAction.cpp" />
104+
<ClCompile Include="stdafx.cpp">
105+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
106+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
107+
</ClCompile>
108+
</ItemGroup>
109+
110+
<ItemGroup>
111+
<None Include="CustomAction.def" />
112+
</ItemGroup>
113+
114+
<ItemGroup>
115+
<ClInclude Include="stdafx.h" />
116+
<ClInclude Include="targetver.h" />
117+
</ItemGroup>
118+
119+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
120+
<Import Project="$(WixNativeCATargetsPath)" Condition=" '$(WixNativeCATargetsPath)' != '' " />
121+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.NativeCA.targets" Condition=" '$(WixNativeCATargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.NativeCA.targets') " />
122+
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixNativeCATargetsImported)' != 'true' ">
123+
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
124+
</Target>
125+
126+
<ImportGroup Label="ExtensionTargets">
127+
</ImportGroup>
128+
</Project>
9.9 KB
Binary file not shown.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<VSTemplate Version="3.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
3+
<TemplateData>
4+
<Name _locID="TSDATA_DUT_Name">C++ Custom Action Project for WiX v3</Name>
5+
<Description _locID="TSDATA_DUT_Description">A project for creating an MSI custom action using WiX Toolset v3</Description>
6+
<Icon>CustomActionCPP.ico</Icon>
7+
<ProjectType>WiX</ProjectType>
8+
<TemplateID>Microsoft.Deployment.WindowsInstaller.CustomActionCPP</TemplateID>
9+
<RequiredFrameworkVersion>2.0</RequiredFrameworkVersion>
10+
<SortOrder>80</SortOrder>
11+
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
12+
<CreateNewFolder>true</CreateNewFolder>
13+
<DefaultName>CustomAction</DefaultName>
14+
<ProvideDefaultName>true</ProvideDefaultName>
15+
</TemplateData>
16+
<TemplateContent>
17+
<Project File="CustomAction.vcxproj" ReplaceParameters="true">
18+
<ProjectItem ReplaceParameters="true" OpenInEditor="true">CustomAction.cpp</ProjectItem>
19+
<ProjectItem ReplaceParameters="true">CustomAction.def</ProjectItem>
20+
<ProjectItem ReplaceParameters="true">stdafx.cpp</ProjectItem>
21+
<ProjectItem>stdafx.h</ProjectItem>
22+
<ProjectItem>targetver.h</ProjectItem>
23+
</Project>
24+
</TemplateContent>
25+
</VSTemplate>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "stdafx.h"
2+
3+
// TODO: reference any additional headers you need in STDAFX.H
4+
// and not in this file
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include "targetver.h"
4+
5+
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
6+
// Windows Header Files:
7+
#include <windows.h>
8+
#include <strsafe.h>
9+
#include <msiquery.h>
10+
11+
// WiX Header Files:
12+
#include <wcautil.h>
13+
14+
15+
// TODO: reference additional headers your program requires here
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#ifndef WINVER // Specifies that the minimum required platform is Windows XP.
4+
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
5+
#endif
6+
7+
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows XP.
8+
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
9+
#endif
10+
11+
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 6.0 SP3.
12+
#define _WIN32_IE 0x0603 // Change this to the appropriate value to target other versions of IE.
13+
#endif
14+
15+
#ifndef _WIN32_MSI // Specifies that the minimum required MSI version is MSI 3.1
16+
#define _WIN32_MSI 310 // Change this to the appropriate value to target other versions of MSI.
17+
#endif

src/Templates/v3/Projects/CustomActionCS/CustomAction.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
<Import Project="$(WixCATargetsPath)" Condition=" '$(WixCATargetsPath)' != '' " />
5454
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets" Condition=" '$(WixCATargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets') " />
5555
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixCATargetsImported)' != 'true' ">
56-
<Error Text="The WiX Toolset v3 build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
56+
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
5757
</Target>
5858
</Project>

src/Templates/v3/Projects/CustomActionCS/CustomActionCS.vstemplate

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<VSTemplate Version="3.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
33
<TemplateData>
4-
<Name _locID="TSDATA_DUT_Name">C# Custom Action Project</Name>
5-
<Description _locID="TSDATA_DUT_Description">A project for creating an MSI custom action</Description>
4+
<Name _locID="TSDATA_DUT_Name">C# Custom Action Project for WiX v3</Name>
5+
<Description _locID="TSDATA_DUT_Description">A project for creating an MSI custom action using WiX Toolset v3</Description>
66
<Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4547" />
77
<ProjectType>WiX</ProjectType>
88
<TemplateID>Microsoft.Deployment.WindowsInstaller.CustomActionCS</TemplateID>

0 commit comments

Comments
 (0)