Packaging for Windows

I can cross-compile my program on Linux and get a .exe file that runs on Windows.That works. But how do I package it without a Windows machine? Do I have to get a signing certificate and all that? Can I do this under Wine?

Depends what you mean by package. If you want to put it into an archive file, you can do it no matter what your platform is without signing your executable.

Usually, signing certificates are not required on Windows but can be nice for your users. If you get to packaging for Mac you might have to get one though, as the platform is more hostile toward unsigned apps.

If by package you mean "create a .exe or .msi for distribution", what do you want to do and how far do you want to go ? If you want to stay in rust's ecosystem, you might want to look into the msi crate, which should provide the kind of basic capability you are looking for : (nb: I have never used it). If you want to go further (certificate inclusion for example), you might have to look for external tools that provide the kind of capability you want and support cross-compilation, however the few I know require licenses.

1 Like

Start here: GitHub - burtonageo/cargo-bundle: Wrap rust executables in OS-specific app bundles

Oh, great, that's what I was looking for.

Except that bundler doesn't really work.

It hasn't been able to package Windows executables since at least 2019. Trying to build for Debian got me "error: No such file or directory (os error 2)" with no explanation of what file it was trying to open..

The basic concept is very good, but the tool was never finished. The original author did the Mac part,
and started on the Windows part. The Windows part is apparently written but failing for obscure Windows related reasons. So this needs attention from someone who lives in the MIcrosoft ecosystem, which I do not.

Huh. I found that from a the Tauri fork which says:

This is a fork of the awesome cargo-bundle, turned into a library used by the Tauri CLI.

And I know that works. Given that cargo-bundle seems active still, I'm surprised it hasn't had any such fixes upstreamed.

Edit: If you don't need cross-platform builds, cargo wix seems like the more maintained option?

1 Like

Nice. cargo install tauri-bundle worked.


  • "Could not find Icon paths." The "icon" entry in Cargo.toml is mandatory, not optional.

  • "Failed to read tauri config: Couldn't get tauri config; please specify the TAURI_CONFIG or TAURI_DIR environment variables". Pointing TAURI_DIR to an empty directory works.

But, no joy:

cargo tauri-bundler  --release --target x86_64-pc-windows-gnu
    Finished release [optimized] target(s) in 0.10s
error: `Native windows bundles not yet supported.`

I'm building a Windows target on Linux. Apparently that doesn't work.

You probably got the year-old 0.9.4 version, the current is 1.0.0-rc.9: but yeah that's going to assume you're bundling a Tauri app. It probably could be convinced to work, but you're probably on your own a bit?

Can I cargo install a nonstandard version? If so, how?

I have a test program, ui-mock. It's a very simple dummy game - 3D window with a cube, some menus on top that open but don't do anything, some buttons. Uses Egui+Rend3->Wgpu->Vulkan/Metal/Dx, so it's bringing in all the heavy machinery for high-performance 3D rendering. It's not a framework, just a test of integration.

Goal is to make that work on the major desktop platforms, cross-compiled. The executables currently work on Linux and Windows, although there's some trouble with full screen. Packaging, not so much.

(I have a much larger system, a metaverse client, currently running as a command line program, which uses the same graphics approach. The idea is to debug all this cross-platform integration and packaging stuff with a small test others can run easily.)

The executable should include a version resource. Without that the installer is going to be unreliable. Microsoft claims a version resource is a requirement.

The executable does not have to be signed. I always do. It's a nice assurance for my audience.

The installer may have to be signed. Microsoft was waffled. At one point a signed installer was a requirement. I believe that is currently not the case.

In any case, your audience will be presented with dire warnings if the installer is not signed. Especially if they download the installer.

I could never get it to work.

AWS is generous with free EC2 Windows instances (micro). In a pinch I've used those for Microsoft specific things. I believe Azure has a similar offering.

If you use WiX, start with the version from Chocolatey. The newest version caused me some problems; I can no longer remember the details.

Oh! I nearly forgot. If your project is open source, CircleCI will build it at no cost. They have a medium Windows available that includes most / all of what you'll need.

Getting a code signing certificate does suck a lot (it's expensive, the process is completely broken the couple of times we've done it so far, and you have to renew each year at full price), but if you don't your users will be presented with a "this isn't trusted" window they might have to find a "more info" subtle button that will give them a "run anyway" option; at least until that build gets enough reputation. This is a dark and mysterious process.

Signing initially means they can always immediately "run anyway", it means that it gets reputation much faster, and it means the reputation carries to other builds with the same certificate. Just don't forget to timestamp or the signature will expire with the certificate!

Cargo install takes a --version option which takes a version range. In this case, something like cargo install tauri-bundler --version ^1.0.0-rc will get you the latest rc version.

cargo install tauri-bundler --version ^1.0.0-rc
    Updating index
  Downloaded tauri-bundler v1.0.0-rc.9
  Downloaded 1 crate (56.5 KB) in 0.63s
error: there is nothing to install in `tauri-bundler v1.0.0-rc.9`, because it has no binaries
`cargo install` is only for installing programs, and can't be used with libraries.
To use a library crate, add it as a dependency in a Cargo project instead.

See this issue:

"You don't need this step anymore (the bundler is show shipped as a library instead of a binary). Why are you trying to install it? Maybe we forgot to update some documentation or you're just trying to use the bundler as a binary yourself?"

It looks like the Tauri crowd broke standalone bundling, and you now have to do everything through the Tauri system, which forces you to use a Tauri architecture, and involves yarn, node, and lots of web app stuff. Which is useless to me, since I;m using a completely different ecosystem - Rend3-Egui-Wgpu-Vulkan.

It turns out that tauri-bundler doesn't actually do the work. It runs "candle.exe" and "light.exe" from Wix. See here.

burtageo/cargo-bundle has code which indicates that dev started to create MSI bundles directly, but that part was never finished. That was "fixed" in Tauri by using Wix to do the work. The Tauri part just seems to take Tauri JSON files and Rust .toml files and crank out Wix bundle language XML files, which then use Wix executables to do the work. Those are Windows executables.

Worse, they're obsolete Windows executables. "candle.exe" and "light.exe" have been subsumed into a new "wix.exe".. That was back in 2021, but doesn't seem to be in the shipping version yet.

At this point, we're totally out of the Rust ecosystem. Wix is in C++ and C#, plus, I think, some opaque DLLs from Microsoft.

Now, all of this is on the way out. Microsoft is phasing out .msi files in favor of .msix files. Which is probably why development of most of these tools seems to have stopped in 2021.

Yep, that sounds about right. It's why I suggested what they forked, because I know the Tauri library does work, and the base cargo-bundler library is still active.

I guess you could keep going and make your own bin wrapping the tauri-bundler library, but that doesn't sound like a good idea.

You can't run the Tauri bundler under Linux anyway, short of some kludge to run the "candle.exe" and "light.exe" binaries under Wine.

The future seems to be going to .msix. Microsoft wants .msix, especially for their "store".Someone is working on that for Rust. See xbuild. They're mobile-first, though, and tied into the Flutter ecosystem. You can build for Android, but not Windows yet. It looks like that's where future work should go.

Like Tauri, they're trying to be comprehensive, perhaps overly so. Their "xbuild" runs Cargo, rather than Cargo running their bundler.

All this for packaging. Building the executable works fine.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.