Skip to content

Commit

Permalink
Add Bundle attribute RunAsAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
nirbar committed Jun 16, 2020
1 parent c73ea2a commit 86c9148
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions Readme.md
Expand Up @@ -2,6 +2,7 @@

[Panel::Software](http://www.panel-sw.co.il) provides a customized edition of WiX built on top of WiX 3.11.2 with the following changes

- [Bundle/@RunAsAdmin](https://github.com/wixtoolset/issues/issues/5309) attribute created a bootstrapper that requires elevation when launched
- [RemotePayload](https://wixtoolset.org/documentation/manual/v3/xsd/wix/remotepayload.html) can be specified on any package payload rather than the main setup file
- Add [heat.exe](https://wixtoolset.org/documentation/manual/v3/overview/heat.html) harvest type "payload_dir" to harvest a PayloadGroup. Specify _-url link_ to set base DownloadUrl for remote paylodas
- Fix WiX issue [6144](https://github.com/wixtoolset/issues/issues/6144): Support multiple attached containers in bundles. Allow bootstrappers larger than 2GB
Expand Down
1 change: 1 addition & 0 deletions src/Setup/Nupkg/WiX.nuspec
Expand Up @@ -83,6 +83,7 @@
<file src="build\ship\x86\WixUtilExtension.dll" target="tools\bin\WixUtilExtension.dll" />
<file src="build\ship\x86\WixVSExtension.dll" target="tools\bin\WixVSExtension.dll" />
<file src="build\ship\x86\x86\burn.exe" target="tools\bin\x86\burn.exe" />
<file src="build\ship\x86\x86\burn-admin.exe" target="tools\bin\x86\burn-admin.exe" />

<file src="build\ship\x86\BootstrapperCore.config" target="tools\sdk\BootstrapperCore.config" />
<file src="build\ship\x86\BootstrapperCore.dll" target="tools\sdk\BootstrapperCore.dll" />
Expand Down
3 changes: 3 additions & 0 deletions src/Setup/Zip/binaries.zipproj
Expand Up @@ -52,6 +52,9 @@
<Stage Include="$(OutputPath)x86\burn.exe">
<StageSubDirectory>x86</StageSubDirectory>
</Stage>
<Stage Include="$(OutputPath)x86\burn-admin.exe">
<StageSubDirectory>x86</StageSubDirectory>
</Stage>
<Stage Include="$(OutputPath_arm)arm\burn.exe" Condition=" Exists('$(OutputPath_arm)arm\burn.exe') ">
<StageSubDirectory>arm</StageSubDirectory>
</Stage>
Expand Down
1 change: 1 addition & 0 deletions src/burn/burn.proj
Expand Up @@ -9,6 +9,7 @@
</ProjectReference>

<ProjectReference Include="stub\Stub.vcxproj" />
<ProjectReference Include="stub\Stub-admin.vcxproj" />

<ProjectReference Include="Samples\ManagedBundleRunner\ManagedBundleRunner.csproj" />
<ProjectReference Include="Samples\runbundle\runbundle.csproj" />
Expand Down
21 changes: 21 additions & 0 deletions src/burn/stub/Stub-admin.vcxproj
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->


<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<TargetName>burn-admin</TargetName>
</PropertyGroup>

<Import Project="$(MSBuildProjectDirectory)\Stub.vcxproj" />

<ItemGroup>
<Manifest Remove="*.*"/>
<Manifest Include="stub-admin.manifest"/>
</ItemGroup>
<ItemDefinitionGroup>
<Link>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
</ItemDefinitionGroup>
</Project>
2 changes: 1 addition & 1 deletion src/burn/stub/Stub.vcxproj
Expand Up @@ -27,7 +27,7 @@
<Keyword>Win32Proj</Keyword>
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<TargetName>burn</TargetName>
<TargetName Condition=" '$(TargetName)'=='' ">burn</TargetName>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), wix.proj))\tools\WixBuild.props" />
Expand Down
17 changes: 17 additions & 0 deletions src/burn/stub/stub-admin.manifest
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- 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. -->


<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity name="setup.exe" version="1.0.0.0" processorArchitecture="x86" type="win32"/>
<description>WiX Toolset Bootstrapper</description>
<dependency><dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" /></dependentAssembly></dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application></compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><requestedExecutionLevel level="requireAdministrator" uiAccess="false"/></requestedPrivileges></security></trustInfo>
</assembly>
2 changes: 1 addition & 1 deletion src/tools/wix/Binder.cs
Expand Up @@ -3813,7 +3813,7 @@ private bool BindBundle(Output bundle, string bundleFile)
stubPlatform = bundleInfo.Platform.ToString();
}
string wixExeDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), stubPlatform);
string stubFile = Path.Combine(wixExeDirectory, "burn.exe");
string stubFile = Path.Combine(wixExeDirectory, bundleInfo.RunAsAdmin ? "burn-admin.exe" : "burn.exe");
string bundleTempPath = Path.Combine(this.TempFilesLocation, Path.GetFileName(bundleFile));

this.core.OnMessage(WixVerboses.GeneratingBundle(bundleTempPath, stubFile));
Expand Down
5 changes: 5 additions & 0 deletions src/tools/wix/Compiler.cs
Expand Up @@ -19929,6 +19929,7 @@ private void ParseBundleElement(XmlNode node)
string logVariablePrefixAndExtension = null;
string iconSourceFile = null;
string splashScreenSourceFile = null;
YesNoType runAsAdmin = YesNoType.No;

// Process only standard attributes until the active section is initialized.
foreach (XmlAttribute attrib in node.Attributes)
Expand Down Expand Up @@ -19994,6 +19995,9 @@ private void ParseBundleElement(XmlNode node)
case "SplashScreenSourceFile":
splashScreenSourceFile = this.core.GetAttributeValue(sourceLineNumbers, attrib);
break;
case "RunAsAdmin":
runAsAdmin = this.core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
break;
case "Tag":
tag = this.core.GetAttributeValue(sourceLineNumbers, attrib);
break;
Expand Down Expand Up @@ -20194,6 +20198,7 @@ private void ParseBundleElement(XmlNode node)
row[17] = this.currentPlatform.ToString();
row[18] = parentName;
row[19] = upgradeCode;
row[23] = (runAsAdmin == YesNoType.Yes) ? 1 : 0;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/tools/wix/Data/tables.xml
Expand Up @@ -1668,6 +1668,7 @@
<columnDefinition name="BundleId" type="string" length="38" category="guid" description="Only valid after binding." />
<columnDefinition name="ProviderKey" type="string" length="38" category="guid" nullable="yes" description="Only valid after binding." />
<columnDefinition name="PerMachine" type="number" length="2" nullable="yes" minValue="0" maxValue="1" description="Only valid after binding." />
<columnDefinition name="RunAsAdmin" type="number" length="2" nullable="yes" minValue="0" maxValue="1" description="Whether the bootstrapper shoule be launched with admin rights." />
</tableDefinition>
<tableDefinition name="WixApprovedExeForElevation" createSymbols="yes" unreal="yes">
<columnDefinition name="Id" type="string" length="0" category="identifier" primaryKey="yes" />
Expand Down
6 changes: 6 additions & 0 deletions src/tools/wix/WixBundleRow.cs
Expand Up @@ -224,5 +224,11 @@ public bool PerMachine
get { return (null != this.Fields[22].Data && 0 != (int)this.Fields[22].Data); }
set { this.Fields[22].Data = value ? 1 : 0; }
}

public bool RunAsAdmin
{
get { return (null != this.Fields[23].Data && 0 != (int)this.Fields[23].Data); }
set { this.Fields[23].Data = value ? 1 : 0; }
}
}
}
5 changes: 5 additions & 0 deletions src/tools/wix/Xsd/wix.xsd
Expand Up @@ -195,6 +195,11 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="RunAsAdmin" type="YesNoType">
<xs:annotation>
<xs:documentation>Whether the bootstrapper shoule be launched with admin rights. Defaults to 'no'. It is strongly encouraged to launch the bootstrapper with least required privileges, and let WiX elevate as late as possible. However when absolutely required to, set this attribute to 'yes' to launch elevated</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SplashScreenSourceFile" type="xs:string">
<xs:annotation>
<xs:documentation>Path to a bitmap that will be shown as the bootstrapper application is being loaded. If this attribute is not specified, no splash screen will be displayed.</xs:documentation>
Expand Down

0 comments on commit 86c9148

Please sign in to comment.