diff options
Diffstat (limited to 'src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs')
-rw-r--r-- | src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs | 160 |
1 files changed, 3 insertions, 157 deletions
diff --git a/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs b/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs index f4b36ac2..241e3538 100644 --- a/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs +++ b/src/wix/WixToolset.Core.Burn/Bundles/CreateBundleExeCommand.cs | |||
@@ -7,8 +7,6 @@ namespace WixToolset.Core.Burn.Bundles | |||
7 | using System.IO; | 7 | using System.IO; |
8 | using System.Reflection; | 8 | using System.Reflection; |
9 | using System.Runtime.InteropServices; | 9 | using System.Runtime.InteropServices; |
10 | using System.Text; | ||
11 | using System.Xml; | ||
12 | using WixToolset.Data; | 10 | using WixToolset.Data; |
13 | using WixToolset.Data.Burn; | 11 | using WixToolset.Data.Burn; |
14 | using WixToolset.Data.Symbols; | 12 | using WixToolset.Data.Symbols; |
@@ -19,14 +17,13 @@ namespace WixToolset.Core.Burn.Bundles | |||
19 | 17 | ||
20 | internal class CreateBundleExeCommand | 18 | internal class CreateBundleExeCommand |
21 | { | 19 | { |
22 | public CreateBundleExeCommand(IMessaging messaging, IFileSystem fileSystem, IBackendHelper backendHelper, string intermediateFolder, string outputPath, WixBootstrapperApplicationDllSymbol bootstrapperApplicationDllSymbol, WixBundleSymbol bundleSymbol, WixBundleContainerSymbol uxContainer, IEnumerable<WixBundleContainerSymbol> containers) | 20 | public CreateBundleExeCommand(IMessaging messaging, IFileSystem fileSystem, IBackendHelper backendHelper, string intermediateFolder, string outputPath, WixBundleSymbol bundleSymbol, WixBundleContainerSymbol uxContainer, IEnumerable<WixBundleContainerSymbol> containers) |
23 | { | 21 | { |
24 | this.Messaging = messaging; | 22 | this.Messaging = messaging; |
25 | this.FileSystem = fileSystem; | 23 | this.FileSystem = fileSystem; |
26 | this.BackendHelper = backendHelper; | 24 | this.BackendHelper = backendHelper; |
27 | this.IntermediateFolder = intermediateFolder; | 25 | this.IntermediateFolder = intermediateFolder; |
28 | this.OutputPath = outputPath; | 26 | this.OutputPath = outputPath; |
29 | this.BootstrapperApplicationDllSymbol = bootstrapperApplicationDllSymbol; | ||
30 | this.BundleSymbol = bundleSymbol; | 27 | this.BundleSymbol = bundleSymbol; |
31 | this.UXContainer = uxContainer; | 28 | this.UXContainer = uxContainer; |
32 | this.Containers = containers; | 29 | this.Containers = containers; |
@@ -44,8 +41,6 @@ namespace WixToolset.Core.Burn.Bundles | |||
44 | 41 | ||
45 | private string OutputPath { get; } | 42 | private string OutputPath { get; } |
46 | 43 | ||
47 | private WixBootstrapperApplicationDllSymbol BootstrapperApplicationDllSymbol { get; } | ||
48 | |||
49 | private WixBundleSymbol BundleSymbol { get; } | 44 | private WixBundleSymbol BundleSymbol { get; } |
50 | 45 | ||
51 | private WixBundleContainerSymbol UXContainer { get; } | 46 | private WixBundleContainerSymbol UXContainer { get; } |
@@ -76,9 +71,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
76 | 71 | ||
77 | var fourPartVersion = this.GetFourPartVersion(this.BundleSymbol); | 72 | var fourPartVersion = this.GetFourPartVersion(this.BundleSymbol); |
78 | 73 | ||
79 | var applicationManifestData = GenerateApplicationManifest(this.BundleSymbol, this.BootstrapperApplicationDllSymbol, this.OutputPath, fourPartVersion); | 74 | this.UpdateBurnResources(bundleTempPath, this.OutputPath, this.BundleSymbol, fourPartVersion); |
80 | |||
81 | this.UpdateBurnResources(bundleTempPath, this.OutputPath, this.BundleSymbol, fourPartVersion, applicationManifestData); | ||
82 | 75 | ||
83 | // Update the .wixburn section to point to at the UX and attached container(s) then attach the containers | 76 | // Update the .wixburn section to point to at the UX and attached container(s) then attach the containers |
84 | // if they should be attached. | 77 | // if they should be attached. |
@@ -105,150 +98,6 @@ namespace WixToolset.Core.Burn.Bundles | |||
105 | } | 98 | } |
106 | } | 99 | } |
107 | 100 | ||
108 | private static byte[] GenerateApplicationManifest(WixBundleSymbol bundleSymbol, WixBootstrapperApplicationDllSymbol bootstrapperApplicationSymbol, string outputPath, Version windowsAssemblyVersion) | ||
109 | { | ||
110 | const string asmv1Namespace = "urn:schemas-microsoft-com:asm.v1"; | ||
111 | const string asmv3Namespace = "urn:schemas-microsoft-com:asm.v3"; | ||
112 | const string compatv1Namespace = "urn:schemas-microsoft-com:compatibility.v1"; | ||
113 | const string ws2005Namespace = "http://schemas.microsoft.com/SMI/2005/WindowsSettings"; | ||
114 | const string ws2016Namespace = "http://schemas.microsoft.com/SMI/2016/WindowsSettings"; | ||
115 | const string ws2017Namespace = "http://schemas.microsoft.com/SMI/2017/WindowsSettings"; | ||
116 | |||
117 | var bundleFileName = Path.GetFileName(outputPath); | ||
118 | var bundleAssemblyVersion = windowsAssemblyVersion.ToString(); | ||
119 | var bundlePlatform = bundleSymbol.Platform == Platform.X64 ? "amd64" : bundleSymbol.Platform.ToString().ToLower(); | ||
120 | var bundleDescription = bundleSymbol.Name; | ||
121 | |||
122 | using (var memoryStream = new MemoryStream()) | ||
123 | using (var writer = new XmlTextWriter(memoryStream, Encoding.UTF8)) | ||
124 | { | ||
125 | writer.WriteStartDocument(); | ||
126 | |||
127 | writer.WriteStartElement("assembly", asmv1Namespace); | ||
128 | writer.WriteAttributeString("manifestVersion", "1.0"); | ||
129 | |||
130 | writer.WriteStartElement("assemblyIdentity"); | ||
131 | writer.WriteAttributeString("name", bundleFileName); | ||
132 | writer.WriteAttributeString("version", bundleAssemblyVersion); | ||
133 | writer.WriteAttributeString("processorArchitecture", bundlePlatform); | ||
134 | writer.WriteAttributeString("type", "win32"); | ||
135 | writer.WriteEndElement(); // </assemblyIdentity> | ||
136 | |||
137 | if (!String.IsNullOrEmpty(bundleDescription)) | ||
138 | { | ||
139 | writer.WriteStartElement("description"); | ||
140 | writer.WriteString(bundleDescription); | ||
141 | writer.WriteEndElement(); | ||
142 | } | ||
143 | |||
144 | writer.WriteStartElement("dependency"); | ||
145 | writer.WriteStartElement("dependentAssembly"); | ||
146 | writer.WriteStartElement("assemblyIdentity"); | ||
147 | writer.WriteAttributeString("name", "Microsoft.Windows.Common-Controls"); | ||
148 | writer.WriteAttributeString("version", "6.0.0.0"); | ||
149 | writer.WriteAttributeString("processorArchitecture", bundlePlatform); | ||
150 | writer.WriteAttributeString("publicKeyToken", "6595b64144ccf1df"); | ||
151 | writer.WriteAttributeString("language", "*"); | ||
152 | writer.WriteAttributeString("type", "win32"); | ||
153 | writer.WriteEndElement(); // </assemblyIdentity> | ||
154 | writer.WriteEndElement(); // </dependentAssembly> | ||
155 | writer.WriteEndElement(); // </dependency> | ||
156 | |||
157 | writer.WriteStartElement("compatibility", compatv1Namespace); | ||
158 | writer.WriteStartElement("application"); | ||
159 | |||
160 | writer.WriteStartElement("supportedOS"); | ||
161 | writer.WriteAttributeString("Id", "{e2011457-1546-43c5-a5fe-008deee3d3f0}"); // Windows Vista | ||
162 | writer.WriteEndElement(); | ||
163 | writer.WriteStartElement("supportedOS"); | ||
164 | writer.WriteAttributeString("Id", "{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"); // Windows 7 | ||
165 | writer.WriteEndElement(); | ||
166 | writer.WriteStartElement("supportedOS"); | ||
167 | writer.WriteAttributeString("Id", "{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"); // Windows 8 | ||
168 | writer.WriteEndElement(); | ||
169 | writer.WriteStartElement("supportedOS"); | ||
170 | writer.WriteAttributeString("Id", "{1f676c76-80e1-4239-95bb-83d0f6d0da78}"); // Windows 8.1 | ||
171 | writer.WriteEndElement(); | ||
172 | writer.WriteStartElement("supportedOS"); | ||
173 | writer.WriteAttributeString("Id", "{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"); // Windows 10 | ||
174 | writer.WriteEndElement(); | ||
175 | |||
176 | writer.WriteEndElement(); // </application> | ||
177 | writer.WriteEndElement(); // </compatibility> | ||
178 | |||
179 | writer.WriteStartElement("trustInfo", asmv3Namespace); | ||
180 | writer.WriteStartElement("security"); | ||
181 | writer.WriteStartElement("requestedPrivileges"); | ||
182 | writer.WriteStartElement("requestedExecutionLevel"); | ||
183 | writer.WriteAttributeString("level", "asInvoker"); | ||
184 | writer.WriteAttributeString("uiAccess", "false"); | ||
185 | writer.WriteEndElement(); // </requestedExecutionLevel> | ||
186 | writer.WriteEndElement(); // </requestedPrivileges> | ||
187 | writer.WriteEndElement(); // </security> | ||
188 | writer.WriteEndElement(); // </trustInfo> | ||
189 | |||
190 | if (bootstrapperApplicationSymbol.DpiAwareness != WixBootstrapperApplicationDpiAwarenessType.Unaware) | ||
191 | { | ||
192 | string dpiAwareValue = null; | ||
193 | string dpiAwarenessValue = null; | ||
194 | string gdiScalingValue = null; | ||
195 | |||
196 | switch (bootstrapperApplicationSymbol.DpiAwareness) | ||
197 | { | ||
198 | case WixBootstrapperApplicationDpiAwarenessType.GdiScaled: | ||
199 | gdiScalingValue = "true"; | ||
200 | break; | ||
201 | case WixBootstrapperApplicationDpiAwarenessType.PerMonitor: | ||
202 | dpiAwareValue = "true/pm"; | ||
203 | break; | ||
204 | case WixBootstrapperApplicationDpiAwarenessType.PerMonitorV2: | ||
205 | dpiAwareValue = "true/pm"; | ||
206 | dpiAwarenessValue = "PerMonitorV2, PerMonitor"; | ||
207 | break; | ||
208 | case WixBootstrapperApplicationDpiAwarenessType.System: | ||
209 | dpiAwareValue = "true"; | ||
210 | break; | ||
211 | } | ||
212 | |||
213 | writer.WriteStartElement("application", asmv3Namespace); | ||
214 | writer.WriteStartElement("windowsSettings"); | ||
215 | |||
216 | if (dpiAwareValue != null) | ||
217 | { | ||
218 | writer.WriteStartElement("dpiAware", ws2005Namespace); | ||
219 | writer.WriteString(dpiAwareValue); | ||
220 | writer.WriteEndElement(); | ||
221 | } | ||
222 | |||
223 | if (dpiAwarenessValue != null) | ||
224 | { | ||
225 | writer.WriteStartElement("dpiAwareness", ws2016Namespace); | ||
226 | writer.WriteString(dpiAwarenessValue); | ||
227 | writer.WriteEndElement(); | ||
228 | } | ||
229 | |||
230 | if (gdiScalingValue != null) | ||
231 | { | ||
232 | writer.WriteStartElement("gdiScaling", ws2017Namespace); | ||
233 | writer.WriteString(gdiScalingValue); | ||
234 | writer.WriteEndElement(); | ||
235 | } | ||
236 | |||
237 | writer.WriteStartElement("longPathAware", ws2016Namespace); | ||
238 | writer.WriteString("true"); | ||
239 | writer.WriteEndElement(); | ||
240 | |||
241 | writer.WriteEndElement(); // </windowSettings> | ||
242 | writer.WriteEndElement(); // </application> | ||
243 | } | ||
244 | |||
245 | writer.WriteEndDocument(); // </assembly> | ||
246 | writer.Close(); | ||
247 | |||
248 | return memoryStream.ToArray(); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | private Version GetFourPartVersion(WixBundleSymbol bundleSymbol) | 101 | private Version GetFourPartVersion(WixBundleSymbol bundleSymbol) |
253 | { | 102 | { |
254 | // Ensure the bundle info provides a full four-part version. | 103 | // Ensure the bundle info provides a full four-part version. |
@@ -279,7 +128,7 @@ namespace WixToolset.Core.Burn.Bundles | |||
279 | return new Version((int)major, (int)minor, (int)build, (int)revision); | 128 | return new Version((int)major, (int)minor, (int)build, (int)revision); |
280 | } | 129 | } |
281 | 130 | ||
282 | private void UpdateBurnResources(string bundleTempPath, string outputPath, WixBundleSymbol bundleInfo, Version fourPartVersion, byte[] applicationManifestData) | 131 | private void UpdateBurnResources(string bundleTempPath, string outputPath, WixBundleSymbol bundleInfo, Version fourPartVersion) |
283 | { | 132 | { |
284 | const int burnLocale = 1033; | 133 | const int burnLocale = 1033; |
285 | var resources = new ResourceCollection(); | 134 | var resources = new ResourceCollection(); |
@@ -344,9 +193,6 @@ namespace WixToolset.Core.Burn.Bundles | |||
344 | var splashScreenConfigResource = new Resource(ResourceType.RCData, "#1", burnLocale, splashScreenConfig.ToBytes()); | 193 | var splashScreenConfigResource = new Resource(ResourceType.RCData, "#1", burnLocale, splashScreenConfig.ToBytes()); |
345 | resources.Add(splashScreenConfigResource); | 194 | resources.Add(splashScreenConfigResource); |
346 | 195 | ||
347 | var manifestResource = new Resource(ResourceType.Manifest, "#1", burnLocale, applicationManifestData); | ||
348 | resources.Add(manifestResource); | ||
349 | |||
350 | try | 196 | try |
351 | { | 197 | { |
352 | this.FileSystem.ExecuteWithRetries(() => resources.Save(bundleTempPath)); | 198 | this.FileSystem.ExecuteWithRetries(() => resources.Save(bundleTempPath)); |