Add per-platform custom action support.
Bob Arnson committed
Jul 6, 2020 at 12:34 UTC
c134594328bd63fb19b88239694523f04108030e
15 files changed
+166
-45
Sql.wixext.sln
+3
-2
@@ -1,7 +1,7 @@
1
2
Microsoft Visual Studio Solution File, Format Version 12.00
3
-# Visual Studio 15
4
-VisualStudioVersion = 15.0.28010.2016
3
+# Visual Studio Version 16
4
+VisualStudioVersion = 16.0.30204.135
5
MinimumVisualStudioVersion = 10.0.40219.1
6
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlca", "src\ca\sqlca.vcxproj", "{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}"
7
EndProject
@@ -20,6 +20,7 @@ Global
20
EndGlobalSection
21
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22
{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.ActiveCfg = Debug|Win32
23
+ {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.Build.0 = Debug|Win32
24
{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.ActiveCfg = Debug|Win32
25
{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.Build.0 = Debug|Win32
26
{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|Any CPU.ActiveCfg = Release|Win32
src/ca/caDecor.h
new
+13
@@ -0,0 +1,13 @@
1
+#pragma once
2
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
3
+
4
+
5
+#if defined(_M_ARM64)
6
+#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64"
7
+#elif defined(_M_AMD64)
8
+#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64"
9
+#elif defined(_M_ARM)
10
+#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM"
11
+#else
12
+#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86"
13
+#endif
src/ca/precomp.h
+2
@@ -24,3 +24,5 @@
24
#include "sca.h"
25
#include "scacost.h"
26
#include "scasqlstr.h"
27
+
28
+#include "caDecor.h"
src/ca/scadb.cpp
+3
-3
@@ -385,7 +385,7 @@ static HRESULT SchedCreateDatabase(
385
hr = SqlDatabaseExists(psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword, NULL);
386
if (S_FALSE == hr)
387
{
388
- hr = WcaDoDeferredAction(L"RollbackCreateDatabase", pwzCustomActionData, COST_SQL_CREATEDB);
388
+ hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackCreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB);
389
ExitOnFailure(hr, "Failed to schedule RollbackCreateDatabase action");
390
}
391
@@ -444,7 +444,7 @@ static HRESULT SchedCreateDatabase(
444
}
445
446
// schedule the CreateDatabase action
447
- hr = WcaDoDeferredAction(L"CreateDatabase", pwzCustomActionData, COST_SQL_CREATEDB);
447
+ hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB);
448
ExitOnFailure(hr, "Failed to schedule CreateDatabase action");
449
450
LExit:
@@ -491,7 +491,7 @@ HRESULT SchedDropDatabase(
491
hr = WcaWriteStringToCaData(wzPassword, &pwzCustomActionData);
492
ExitOnFailure(hr, "Failed to add user password to CustomActionData");
493
494
- hr = WcaDoDeferredAction(L"DropDatabase", pwzCustomActionData, COST_SQL_DROPDB);
494
+ hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"DropDatabase"), pwzCustomActionData, COST_SQL_DROPDB);
495
ExitOnFailure(hr, "Failed to schedule DropDatabase action");
496
497
LExit:
src/ca/scasqlstr.cpp
+2
-2
@@ -654,7 +654,7 @@ static HRESULT ExecuteStrings(
654
{
655
Assert(pwzCustomActionData && *pwzCustomActionData && uiCost);
656
657
- hr = WcaDoDeferredAction(1 == iOldRollback ? L"RollbackExecuteSqlStrings" : L"ExecuteSqlStrings", pwzCustomActionData, uiCost);
657
+ hr = WcaDoDeferredAction(1 == iOldRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost);
658
ExitOnFailure(hr, "failed to schedule ExecuteSqlStrings action, rollback: %d", iOldRollback);
659
iOldRollback = iRollback;
660
@@ -714,7 +714,7 @@ static HRESULT ExecuteStrings(
714
if (pwzCustomActionData && *pwzCustomActionData)
715
{
716
Assert(pwzCustomActionData && *pwzCustomActionData && uiCost);
717
- hr = WcaDoDeferredAction(1 == iRollback ? L"RollbackExecuteSqlStrings" : L"ExecuteSqlStrings", pwzCustomActionData, uiCost);
717
+ hr = WcaDoDeferredAction(1 == iRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost);
718
ExitOnFailure(hr, "Failed to schedule ExecuteSqlStrings action");
719
720
*pwzCustomActionData = L'\0';
src/ca/sqlca.vcxproj
+25
-1
@@ -14,13 +14,37 @@
14
<Configuration>Release</Configuration>
15
<Platform>Win32</Platform>
16
</ProjectConfiguration>
17
+ <ProjectConfiguration Include="Debug|x64">
18
+ <Configuration>Debug</Configuration>
19
+ <Platform>x64</Platform>
20
+ </ProjectConfiguration>
21
+ <ProjectConfiguration Include="Release|x64">
22
+ <Configuration>Release</Configuration>
23
+ <Platform>x64</Platform>
24
+ </ProjectConfiguration>
25
+ <ProjectConfiguration Include="Debug|ARM">
26
+ <Configuration>Debug</Configuration>
27
+ <Platform>ARM</Platform>
28
+ </ProjectConfiguration>
29
+ <ProjectConfiguration Include="Release|ARM">
30
+ <Configuration>Release</Configuration>
31
+ <Platform>ARM</Platform>
32
+ </ProjectConfiguration>
33
+ <ProjectConfiguration Include="Debug|ARM64">
34
+ <Configuration>Debug</Configuration>
35
+ <Platform>ARM64</Platform>
36
+ </ProjectConfiguration>
37
+ <ProjectConfiguration Include="Release|ARM64">
38
+ <Configuration>Release</Configuration>
39
+ <Platform>ARM64</Platform>
40
+ </ProjectConfiguration>
41
</ItemGroup>
42
43
<PropertyGroup Label="Globals">
44
<ProjectGuid>{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}</ProjectGuid>
45
<ConfigurationType>DynamicLibrary</ConfigurationType>
46
<TargetName>sqlca</TargetName>
23
- <PlatformToolset>v141</PlatformToolset>
47
+ <PlatformToolset>v142</PlatformToolset>
48
<CharacterSet>Unicode</CharacterSet>
49
<ProjectModuleDefinitionFile>sqlca.def</ProjectModuleDefinitionFile>
50
<Description>WiX Toolset Sql CustomAction</Description>
src/wixext/SqlCompiler.cs
+3
-2
@@ -7,6 +7,7 @@ namespace WixToolset.Sql
7
using System.Xml.Linq;
8
using WixToolset.Data;
9
using WixToolset.Extensibility;
10
+ using WixToolset.Extensibility.Data;
11
using WixToolset.Sql.Symbols;
12
13
/// <summary>
@@ -797,8 +798,8 @@ namespace WixToolset.Sql
798
799
private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers)
800
{
800
- this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "InstallSqlData");
801
- this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "UninstallSqlData");
801
+ this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64);
802
+ this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64);
803
}
804
}
805
}
src/wixlib/SqlExtension.wxi
new
+36
@@ -0,0 +1,36 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
+
4
+<Include xmlns="http://wixtoolset.org/schemas/v4/wxs">
5
+ <?include caDecor.wxi ?>
6
+
7
+ <Fragment>
8
+ <UI>
9
+ <ProgressText Action="$(var.Prefix)InstallSqlData$(var.Suffix)">!(loc.ConfigureSql)</ProgressText>
10
+ <ProgressText Action="$(var.Prefix)UninstallSqlData$(var.Suffix)">!(loc.ConfigureSql)</ProgressText>
11
+ <ProgressText Action="$(var.Prefix)CreateDatabase$(var.Suffix)">!(loc.CreateDatabase)</ProgressText>
12
+ <ProgressText Action="$(var.Prefix)DropDatabase$(var.Suffix)">!(loc.DropDatabase)</ProgressText>
13
+ <ProgressText Action="$(var.Prefix)ExecuteSqlStrings$(var.Suffix)">!(loc.ExecuteSqlStrings)</ProgressText>
14
+ <ProgressText Action="$(var.Prefix)RollbackExecuteSqlStrings$(var.Suffix)">!(loc.RollbackExecuteSqlStrings)</ProgressText>
15
+ </UI>
16
+
17
+ <!-- The SQL custom actions impersonate the user because the user's credentials are used when connecting to the database if none are provided. -->
18
+ <CustomAction Id="$(var.Prefix)InstallSqlData$(var.Suffix)" BinaryKey="SqlCA$(var.Suffix)" DllEntry="InstallSqlData" Execute="immediate" Return="check" />
19
+ <CustomAction Id="$(var.Prefix)UninstallSqlData$(var.Suffix)" BinaryKey="SqlCA$(var.Suffix)" DllEntry="UninstallSqlData" Execute="immediate" Return="check" />
20
+ <CustomAction Id="$(var.Prefix)CreateDatabase$(var.Suffix)" BinaryKey="SqlCA$(var.Suffix)" DllEntry="CreateDatabase" Execute="deferred" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
21
+ <CustomAction Id="$(var.Prefix)RollbackCreateDatabase$(var.Suffix)" BinaryKey="SqlCA$(var.Suffix)" DllEntry="DropDatabase" Execute="rollback" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
22
+ <CustomAction Id="$(var.Prefix)DropDatabase$(var.Suffix)" BinaryKey="SqlCA$(var.Suffix)" DllEntry="DropDatabase" Execute="deferred" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
23
+ <CustomAction Id="$(var.Prefix)ExecuteSqlStrings$(var.Suffix)" BinaryKey="SqlCA$(var.Suffix)" DllEntry="ExecuteSqlStrings" Execute="deferred" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
24
+ <CustomAction Id="$(var.Prefix)RollbackExecuteSqlStrings$(var.Suffix)" BinaryKey="SqlCA$(var.Suffix)" DllEntry="ExecuteSqlStrings" Execute="rollback" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
25
+
26
+ <InstallExecuteSequence>
27
+ <Custom Action="$(var.Prefix)UninstallSqlData$(var.Suffix)" Before="RemoveFiles" Overridable="yes">NOT SKIPUNINSTALLSQLDATA AND VersionNT > 400</Custom>
28
+ <Custom Action="$(var.Prefix)InstallSqlData$(var.Suffix)" After="InstallFiles" Overridable="yes">NOT SKIPINSTALLSQLDATA AND VersionNT > 400</Custom>
29
+ </InstallExecuteSequence>
30
+ </Fragment>
31
+
32
+ <!-- Server Custom Action DLL Definitions -->
33
+ <Fragment>
34
+ <Binary Id="SqlCA$(var.Suffix)" SourceFile="!(bindpath.$(var.platform))sqlca.dll" />
35
+ </Fragment>
36
+</Include>
src/wixlib/SqlExtension.wxs
-29
@@ -1,12 +1,9 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
4
-
4
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
5
<?include caerr.wxi ?>
6
8
- <!-- Server Custom Action Definitions -->
9
-
7
<Fragment>
8
<UI>
9
<Error Id="$(var.msierrSQLFailedCreateDatabase)">!(loc.msierrSQLFailedCreateDatabase)</Error>
@@ -14,32 +11,6 @@
11
<Error Id="$(var.msierrSQLFailedConnectDatabase)">!(loc.msierrSQLFailedConnectDatabase)</Error>
12
<Error Id="$(var.msierrSQLFailedExecString)">!(loc.msierrSQLFailedExecString)</Error>
13
<Error Id="$(var.msierrSQLDatabaseAlreadyExists)">!(loc.msierrSQLDatabaseAlreadyExists)</Error>
17
-
18
- <ProgressText Action="InstallSqlData">!(loc.ConfigureSql)</ProgressText>
19
- <ProgressText Action="UninstallSqlData">!(loc.ConfigureSql)</ProgressText>
20
- <ProgressText Action="CreateDatabase">!(loc.CreateDatabase)</ProgressText>
21
- <ProgressText Action="DropDatabase">!(loc.DropDatabase)</ProgressText>
22
- <ProgressText Action="ExecuteSqlStrings">!(loc.ExecuteSqlStrings)</ProgressText>
23
- <ProgressText Action="RollbackExecuteSqlStrings">!(loc.RollbackExecuteSqlStrings)</ProgressText>
14
</UI>
25
-
26
- <!-- The SQL custom actions should impersonate the user because the user"s cridentials are used when connected to the database if none are provided -->
27
- <CustomAction Id="InstallSqlData" BinaryKey="SqlCA" DllEntry="InstallSqlData" Execute="immediate" Return="check" />
28
- <CustomAction Id="UninstallSqlData" BinaryKey="SqlCA" DllEntry="UninstallSqlData" Execute="immediate" Return="check" />
29
- <CustomAction Id="CreateDatabase" BinaryKey="SqlCA" DllEntry="CreateDatabase" Execute="deferred" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
30
- <CustomAction Id="RollbackCreateDatabase" BinaryKey="SqlCA" DllEntry="DropDatabase" Execute="rollback" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
31
- <CustomAction Id="DropDatabase" BinaryKey="SqlCA" DllEntry="DropDatabase" Execute="deferred" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
32
- <CustomAction Id="ExecuteSqlStrings" BinaryKey="SqlCA" DllEntry="ExecuteSqlStrings" Execute="deferred" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
33
- <CustomAction Id="RollbackExecuteSqlStrings" BinaryKey="SqlCA" DllEntry="ExecuteSqlStrings" Execute="rollback" Return="check" HideTarget="yes" SuppressModularization="yes" TerminalServerAware="yes" />
34
-
35
- <InstallExecuteSequence>
36
- <Custom Action="UninstallSqlData" Before="RemoveFiles" Overridable="yes">NOT SKIPUNINSTALLSQLDATA AND VersionNT > 400</Custom>
37
- <Custom Action="InstallSqlData" After="InstallFiles" Overridable="yes">NOT SKIPINSTALLSQLDATA AND VersionNT > 400</Custom>
38
- </InstallExecuteSequence>
39
- </Fragment>
40
-
41
- <!-- Server Custom Action DLL Definitions -->
42
- <Fragment>
43
- <Binary Id="SqlCA" SourceFile="sqlca.dll" />
15
</Fragment>
16
</Wix>
src/wixlib/SqlExtension_arm.wxs
new
+8
@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
+
4
+
5
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
6
+ <?define platform=arm ?>
7
+ <?include SqlExtension.wxi ?>
8
+</Wix>
src/wixlib/SqlExtension_arm64.wxs
new
+8
@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
+
4
+
5
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
6
+ <?define platform=arm64 ?>
7
+ <?include SqlExtension.wxi ?>
8
+</Wix>
src/wixlib/SqlExtension_x64.wxs
new
+8
@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
+
4
+
5
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
6
+ <?define platform=x64 ?>
7
+ <?include SqlExtension.wxi ?>
8
+</Wix>
src/wixlib/SqlExtension_x86.wxs
new
+8
@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
+
4
+
5
+<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
6
+ <?define platform=x86 ?>
7
+ <?include SqlExtension.wxi ?>
8
+</Wix>
src/wixlib/caDecor.wxi
new
+40
@@ -0,0 +1,40 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
3
+
4
+
5
+<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
6
+ <?ifdef Prefix ?>
7
+ <?undef Prefix ?>
8
+ <?endif ?>
9
+
10
+ <?define Prefix="Wix4" ?>
11
+
12
+ <?ifndef platform ?>
13
+ <?define platform="x86" ?>
14
+ <?endif ?>
15
+
16
+ <?if $(var.platform)="" ?>
17
+ <?undef platform ?>
18
+ <?define platform="x86" ?>
19
+ <?endif ?>
20
+
21
+ <?ifdef Suffix ?>
22
+ <?undef Suffix ?>
23
+ <?endif ?>
24
+
25
+ <?if $(var.platform)~="x86" ?>
26
+ <?define Suffix="_X86" ?>
27
+ <?endif ?>
28
+
29
+ <?if $(var.platform)~="x64" ?>
30
+ <?define Suffix="_X64" ?>
31
+ <?endif ?>
32
+
33
+ <?if $(var.platform)~="arm" ?>
34
+ <?define Suffix="_A32" ?>
35
+ <?endif ?>
36
+
37
+ <?if $(var.platform)~="arm64" ?>
38
+ <?define Suffix="_A64" ?>
39
+ <?endif ?>
40
+</Include>
src/wixlib/sql.wixproj
+7
-6
@@ -1,18 +1,19 @@
1
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -->
2
<Project Sdk="WixToolset.Sdk">
3
-
3
<PropertyGroup>
4
<OutputType>Library</OutputType>
5
<BindFiles>true</BindFiles>
6
<Cultures>en-us</Cultures>
7
</PropertyGroup>
9
-
8
+
9
<ItemGroup>
11
- <ProjectReference Include="..\ca\sqlca.vcxproj" />
10
+ <ProjectReference Include="..\ca\sqlca.vcxproj" Properties="Platform=ARM" />
11
+ <ProjectReference Include="..\ca\sqlca.vcxproj" Properties="Platform=ARM64" />
12
+ <ProjectReference Include="..\ca\sqlca.vcxproj" Properties="Platform=x86" />
13
+ <ProjectReference Include="..\ca\sqlca.vcxproj" Properties="Platform=x64" />
14
</ItemGroup>
13
-
15
+
16
<ItemGroup>
17
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" />
18
</ItemGroup>
17
-
18
-</Project>
19
+</Project>
\ No newline at end of file