Skip to content

Commit

Permalink
feat(tauri-build): add option to specify Windows manifest, closes #5584
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Nov 30, 2022
1 parent b6027b2 commit 4c58b4f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .changes/cli-no-dev-server.md
@@ -1,5 +1,5 @@
---
"cli.rs": "patch"
"cli.rs": "minor"
---

Add `--no-dev-server` flag to the cli to disable the dev server for static files in dev mode.
7 changes: 7 additions & 0 deletions .changes/tauri-build-windows-manifest.md
@@ -0,0 +1,7 @@
---
"tauri-build": "minor"
---

Add `WindowsAttributes::app_manifest` to specify the application manifest on Windows.


41 changes: 25 additions & 16 deletions core/tauri-build/src/lib.rs
Expand Up @@ -110,6 +110,15 @@ pub struct WindowsAttributes {
///
/// If it is left unset, it will look up a path in the registry, i.e. HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots
sdk_dir: Option<PathBuf>,
/// A string containing an [application manifest] to be included with the application on Windows.
///
/// Defaults to:
/// ```
#[doc = include_str!("window-app-manifest.xml")]
/// ```
///
/// [application manifest]: https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests
app_manifest: Option<String>,
}

impl WindowsAttributes {
Expand All @@ -135,6 +144,18 @@ impl WindowsAttributes {
self.sdk_dir = Some(sdk_dir.as_ref().into());
self
}

/// Sets the app manifest. Currently only used on Windows.
///
/// Defaults to:
/// ```
#[doc = include_str!("window-app-manifest.xml")]
/// ```
#[must_use]
pub fn app_manifest<S: AsRef<str>>(mut self, manifest: S) -> Self {
self.app_manifest = Some(manifest.as_ref().to_string());
self
}
}

/// The attributes used on the build.
Expand Down Expand Up @@ -337,22 +358,10 @@ pub fn try_build(attributes: Attributes) -> Result<()> {
let mut res = WindowsResource::new();

res.set_manifest(
r#"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
"#,
&attributes
.windows_attributes
.app_manifest
.unwrap_or(include_str!("window-app-manifest.xml").to_string()),
);

if let Some(sdk_dir) = &attributes.windows_attributes.sdk_dir {
Expand Down
14 changes: 14 additions & 0 deletions core/tauri-build/src/window-app-manifest.xml
@@ -0,0 +1,14 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

3 comments on commit 4c58b4f

@CaptainIsaaca
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great but I can't find it in the current documentation. I'm a JS developer so I can't wrap my head about how to use it in rust. Can we have a small example on how to use it in main.rs for example.

Thanks

@amrbashir
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this hasn't been merged yet, see #5730

@CaptainIsaaca
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks for the quick reply. This is the reason I couldn't get it to work in the past 3 hours 🥇. (Kindly check your email/twitter too).

Please sign in to comment.