首页 > 编程语言 >折腾笔记[2]-跨平台打包tauri程序

折腾笔记[2]-跨平台打包tauri程序

时间:2024-10-06 13:10:55浏览次数:1  
标签:Windows tauri NSIS 跨平台 Unicode 安装程序 your 打包

摘要

在macOS(arm64)平台打包tauri程序到Windows(amd64)平台.

Abstract

Packaging a Tauri application for the Windows (amd64) platform from macOS (arm64).

关键信息

  • 构建平台:macOS 14.6.1 (arm64)
  • 目标平台:Window10 (amd64)

原理简介

nsis简介

[https://nsis.sourceforge.io/Docs/Chapter1.html#intro-about]
The installer is your application's first impression. Slow or unsuccessful software installations is one of the most irritating computer problems. A quick and user friendly installer is therefore an essential part of your software product. NSIS (Nullsoft Scriptable Install System) is a tool that allows programmers to create such installers for Windows. It is released under an open source license and is completely free for any use.

NSIS creates installers that are capable of installing, uninstalling, setting system settings, extracting files, etc. Because it's based on script files you can fully control every part of your installer. The scripting language supports variables, functions and string manipulation, just like a normal programming language - but designed for the creation of installers. Even with all these features, NSIS is still the smallest installer system available. With the default options, it has an overhead of only 34 KB.

Starting with NSIS v3.0 you can choose to create Unicode installers by setting the Unicode attribute. These installers will not work on Windows 95/98/ME but they will allow you to display your installer in any Unicode language supported by the OS.

When building a Unicode installer NSIS variables can hold Unicode characters (0001-FFFF). There should be no need to modify your existing scripts. If you want to read/write Unicode files, specific instructions have been added to read/write UTF-16LE strings from/to disk.

安装程序是您的应用程序的第一印象。软件安装缓慢或失败是计算机问题中最令人烦恼的之一。因此,一个快速且用户友好的安装程序是您的软件产品的重要组成部分。NSIS(Nullsoft Scriptable Install System)是一个允许程序员为Windows创建此类安装程序的工具。它是在开源许可下发布的,可以完全免费使用。

NSIS创建的安装程序能够安装、卸载、设置系统设置、提取文件等。因为它基于脚本文件,所以您可以完全控制安装程序的每一个部分。脚本语言支持变量、函数和字符串操作,就像普通的编程语言一样,但它是为创建安装程序而设计的。即使拥有所有这些功能,NSIS仍然是可用的最小安装程序系统。使用默认选项,它只有34 KB的开销。

从NSIS v3.0开始,您可以选择通过设置Unicode属性来创建Unicode安装程序。这些安装程序在Windows 95/98/ME上无法工作,但它们将允许您在操作系统支持的任何Unicode语言中显示您的安装程序。

在构建Unicode安装程序时,NSIS变量可以保存Unicode字符(0001-FFFF)。您应该不需要修改现有的脚本。如果您想要读写Unicode文件,已经添加了特定的指令来从磁盘读取/写入UTF-16LE字符串。

msvc简介

[https://zhuanlan.zhihu.com/p/702329030]
简单的说:MSVC 是微软 C/C++ 语言以及相关工具集

语言相关包括:MSVC++ 语言 ,MSVC C++ 库(微软自称 STL:C++ standard library,是的,不是你理解的那个 stl )。
相关工具及包括了:编译链接工具 cl.exe link.exe rc.exe 等。

广义上讲,Windows SDK 包括了在对应版本操作系统的头文件和系统的导入库,最终指向了可能包括了 Kernel32.dll、 Advapi32.dll 等,我们可以称之为 Win32 子系统动态链接库,(Windows 包括多个子系统,甚至包括 POSIX 子系统 ).

在这个过程中 SDK 只是一些可能包括了一些参数检查,转换参数,调用内部函数 如 CreateFile 最终经过一系列操作后,最后调用了 NtCreateFile 函数,该函数并不存在于 SDK ,甚至不存在于 Win32 subsystem 的 dll 中,而是存在于 ntdll.dll 中(native dll),在这里发生了真正的系统调用,并最终根据系统调用号系统调用。

tauri跨平台打包

[https://v1.tauri.app/v1/guides/building/cross-platform/]
[https://nsis.sourceforge.io/Docs/AppendixG.html]
[https://nsis-dev.github.io/NSIS-Forums/html/t-276382.html]
[https://github.com/jcsteh/osara/issues/89]
[https://github.com/ContinuumIO/anaconda-recipes/issues/86]
Tauri v1.3 added a new Windows installer type based on the NSIS installer framework. In contrast to WiX, NSIS itself can also work on Linux and macOS which makes it possible to build many Tauri apps on non-Windows hosts. Note that this is currently considered highly experimental and may not work on every system or for every project. Therefore it should only be used as a last resort if local VMs or CI solutions like GitHub Actions don't work for you. Note that, at this time, signing cross-platform builds is currently unsupported.

Tauri v1.3增加了一种新的Windows安装程序类型,基于NSIS安装程序框架。与WiX不同,NSIS本身也可以在Linux和macOS上运行,这使得在非Windows主机上构建许多Tauri应用程序成为可能。请注意,这目前被认为是高度实验性的,可能不会在每一个系统或每一个项目中都有效。因此,它应该只作为最后的手段使用,如果本地虚拟机或CI解决方案(如GitHub Actions)对您不起作用的话。请注意,目前不支持对跨平台构建进行签名。

实现

步骤

cargo create-tauri-app
# ✔ Project name · tauri-app
# ✔ Identifier · com.tauri-app.app
# ✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, bun)
# ✔ Choose your package manager · npm
# ✔ Choose your UI template · Vue - (https://vuejs.org/)
# ✔ Choose your UI flavor · JavaScript
npm run tauri dev
brew install nsis
rustup target add x86_64-pc-windows-msvc
cargo install --locked cargo-xwin
sudo mkdir /opt/homebrew/Cellar/makensis/3.10/share/nsis
sudo cp -r /opt/homebrew/Homebrew/Cellar/makensis/3.10/share/nsis/** /opt/homebrew/Cellar/makensis/3.10/share/nsis
npm run tauri build -- --runner cargo-xwin --target x86_64-pc-windows-msvc

效果

成功在Windows运行

联系方式

如果对本文有疑问或者提出建议可评论区留言或者发送邮件到[email protected].
分割线

标签:Windows,tauri,NSIS,跨平台,Unicode,安装程序,your,打包
From: https://www.cnblogs.com/qsbye/p/18449010

相关文章

  • 历经十年/头发都快掉光/秘钥生成器终极版/机器码/到期功能限制/运行时间限制/日期防篡
    一、项目介绍1.0前言说明标题一点都不夸张,从第一版的秘钥生成器到今天这个版本,确实经历了十年的时间,最初的版本做的非常简陋,就是搞了个异或加密,控制运行时间,后面又增加设备数量的控制,然后就是到期时间的限制。这种有个巨大缺陷就是可复制性,如果将授权的秘钥文件,拷贝到其他电脑......
  • 打包网页的一次尝试
    1.下载Node.js更换cnpm:npminstall-gcnpm--registry=https://registry.npmmirror.com在C:\Users\Administrator\.npmrc中添加源registry=https://registry.npmmirror.comdisturl=https://registry.npmmirror.com/-/binary/nodeelectron_mirror=https://cdn.npmmirror.co......
  • 打包压缩三剑客
    打包压缩三剑客1.tartar命令选项完全简写创建压缩包tarzcvf/tmp/etc.tar.gz/etc/tarzcf/tmp/etc.tar.gz/etc/查看压缩包内容tarztvf/tmp/etc.tar.gztartf/tmp/etc.tar.gz解压tarzxvf/tmp/etc.tar.gztarxf/tmp/etc.tar.gz解压到指定......
  • 玄武星辰大阵——软件终端架构思维———未来之窗行业应用跨平台架构
    一、创生-玄武星辰大阵随着互联网的高速发展,企业的数字化进程不断加速,每个公司所涉及的业务日益繁多。少则数种,多则上千种,业务的复杂性催生了庞大而庞杂的系统。在这些系统中,重复功能屡见不鲜,重复的系统架构比比皆是。这不仅给维护工作带来了极大的挑战,也导致了大量的重复劳动......
  • vite5+tauri2.0+vue3+rust桌面exe聊天系统演示
    Tauri2.0-Vue3Chat:自研基于tauri2.0+rust+vue3setup+pinia2+element-plus等技术搭建的一款高颜值仿QQ/微信客户端聊天EXE软件。整个聊天窗口采用自定义无边框透明圆角阴影UI模式。tauri2.0-vitechat:自研vue3+tauri2+element-plus客户端聊天程序项目特点整体窗口采......
  • 修改vue打包后的结构
    当一个项目需要在调用另一个项目作为子项目时,即两个vue项目,在nginx中配置两处前端,可能就需要区分两个vue项目打包后的地址1.在dist后再加一层子文件夹如childrenmodule.exports={publicPath:"children"outputDir:"dist/children",//用于放置生成的静态资源(js、cs......
  • python 使用 pyinstaller 打包
    python使用pyinstaller打包1、下载pyinstallerpipinstallpyinstaller2、在当前目录下生成.spec文件注意,这行命令在生成文件的时候,也打包了输出物pyinstaller--name=pytaskermain.py--onefile--specpath=.2.1、生成的目录结构D:.│main.py│pytasker.spe......
  • .NET跨平台绘图基础库--SkiaSharp
    .NET跨平台绘图基础库--SkiaSharp SkiaSharp是一个跨平台的2D图形API,用于.NET平台,基于Google的Skia图形库。它提供了全面的2DAPI,可以在移动、服务器和桌面模型上渲染图像。SkiaSharp可以在多个.NET平台上使用,包括ASP.NETCore、WPF、Winform、MAUI、Avalonia......
  • Python打包工具之pyinstaller
    前言:近期使用PySimpleGUI开发了一款开发者工具X-助手工具,意打造成平常开发助手,无论是图片还是网址的处理等等都需要这一个工具即可,无需在网上找各个网站去找解决方案,对于GUI的打包工具,在Python领域pyinstaller较为流行工具样例:   安装:pipinstall-Upyins......
  • Electron慢,QT贵,有没有第三选择?试试Tauri
    桌面程序开发页面也面临着前端技术栈的选择,Electron、QT和Tauri算是各有千秋,Electron在处理大量文件时候,非常耗费资源,QT倒是没有这方面问题,但是收费忒贵了,Tauri作为后起之秀,有无弯道超车的机会呢?一、electron、qd和tauri的由来和基本信息1.Electron:-由来:Electron最初......