Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tauri-build): add option to specify Windows manifest, closes #5584 #5730

Merged
merged 5 commits into from Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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:
/// ```ignore
#[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:
/// ```ignore
#[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>