@@ -110,6 +110,15 @@ pub struct WindowsAttributes {
110110 ///
111111 /// If it is left unset, it will look up a path in the registry, i.e. HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots
112112 sdk_dir : Option < PathBuf > ,
113+ /// A string containing an [application manifest] to be included with the application on Windows.
114+ ///
115+ /// Defaults to:
116+ /// ```ignore
117+ #[ doc = include_str ! ( "window-app-manifest.xml" ) ]
118+ /// ```
119+ ///
120+ /// [application manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
121+ app_manifest : Option < String > ,
113122}
114123
115124impl WindowsAttributes {
@@ -135,6 +144,45 @@ impl WindowsAttributes {
135144 self . sdk_dir = Some ( sdk_dir. as_ref ( ) . into ( ) ) ;
136145 self
137146 }
147+
148+ /// Sets the Windows app [manifest].
149+ ///
150+ /// # Example
151+ ///
152+ /// The following manifest will brand the exe as requesting administrator privileges.
153+ /// Thus, everytime it is executed, a Windows UAC dialog will appear.
154+ ///
155+ /// Note that you can move the manifest contents to a separate file and use `include_str!("manifest.xml")`
156+ /// instead of the inline string.
157+ ///
158+ /// ```rust,no_run
159+ /// let mut windows = tauri_build::WindowsAttributes::new();
160+ /// windows = windows.app_manifest(r#"
161+ /// <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
162+ /// <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
163+ /// <security>
164+ /// <requestedPrivileges>
165+ /// <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
166+ /// </requestedPrivileges>
167+ /// </security>
168+ /// </trustInfo>
169+ /// </assembly>
170+ /// "#);
171+ /// tauri_build::try_build(
172+ /// tauri_build::Attributes::new().windows_attributes(windows)
173+ /// ).expect("failed to run build script");
174+ /// ```
175+ ///
176+ /// Defaults to:
177+ /// ```ignore
178+ #[ doc = include_str ! ( "window-app-manifest.xml" ) ]
179+ /// [manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
180+ /// ```
181+ #[ must_use]
182+ pub fn app_manifest < S : AsRef < str > > ( mut self , manifest : S ) -> Self {
183+ self . app_manifest = Some ( manifest. as_ref ( ) . to_string ( ) ) ;
184+ self
185+ }
138186}
139187
140188/// The attributes used on the build.
@@ -336,24 +384,11 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
336384 if window_icon_path. exists ( ) {
337385 let mut res = WindowsResource :: new ( ) ;
338386
339- res. set_manifest (
340- r#"
341- <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
342- <dependency>
343- <dependentAssembly>
344- <assemblyIdentity
345- type="win32"
346- name="Microsoft.Windows.Common-Controls"
347- version="6.0.0.0"
348- processorArchitecture="*"
349- publicKeyToken="6595b64144ccf1df"
350- language="*"
351- />
352- </dependentAssembly>
353- </dependency>
354- </assembly>
355- "# ,
356- ) ;
387+ if let Some ( manifest) = attributes. windows_attributes . app_manifest {
388+ res. set_manifest ( & manifest) ;
389+ } else {
390+ res. set_manifest ( include_str ! ( "window-app-manifest.xml" ) ) ;
391+ }
357392
358393 if let Some ( sdk_dir) = & attributes. windows_attributes . sdk_dir {
359394 if let Some ( sdk_dir_str) = sdk_dir. to_str ( ) {
0 commit comments