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

Could not open resource.rc when using compile_for #11

Open
xNyaDev opened this issue Jun 11, 2023 · 1 comment
Open

Could not open resource.rc when using compile_for #11

xNyaDev opened this issue Jun 11, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@xNyaDev
Copy link

xNyaDev commented Jun 11, 2023

I am trying to use tauri_winres to add resources to a single binary using the new compile_for method added in 0.1.1. I am using the following code:

fn main() {
    #[cfg(feature = "cli")]
    if std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "windows" {
        tauri_winres::WindowsResource::new()
            .set("FileDescription", "bfstool-cli")
            .set(
                "LegalCopyright",
                "Licensed under MIT or Apache-2.0, xNyaDev 2023",
            )
            .set("OriginalFilename", "bfstool-cli.exe")
            .set("ProductName", "bfstool-cli")
            .compile_for(&["bfstool-cli"])
            .unwrap();
    }
}

My crate is a Rust library (no cdylib) with a single binary target. Running cargo build results in:

   Compiling bfstool v2.0.0 (C:\Users\xNya\Documents\Projects\bfstool)
error: failed to run custom build command for `bfstool v2.0.0 (C:\Users\xNya\Documents\Projects\bfstool)`

Caused by:
  process didn't exit successfully: `C:\Users\xNya\Documents\Projects\bfstool\target\debug\build\bfstool-cfbe2ae6d3aaf1dc\build-script-build` (exit code: 101)
  --- stdout
  package.metadata does not exist
  Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
  Copyright (C) Microsoft Corporation.  All rights reserved.

  fatal error RC1110: could not open resource.rc

  --- stderr
  thread 'main' panicked at 'RC.EXE failed to compile specified resource file', C:\Users\xNya\.cargo\registry\src\index.crates.io-6f17d22bba15001f\embed-resource-2.1.1\src\windows_msvc.rs:39:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The line package.metadata does not exist is expected as my Cargo.toml contains no resource fields and everything is set in the above build script.

If you need the entire crate to reproduce the issue, the source code is located here: https://github.com/xNyaDev/bfstool. It is currently using the code I wrote for #8 (and therefore builds fine), changing it to upstream requires modifying Cargo.toml to use tauri-winres 0.1.1 and changing the compile_for call in the build script.

@FabianLars FabianLars self-assigned this Jun 11, 2023
@FabianLars
Copy link
Member

Thanks for the report! So far i'm still trying to figure out why this happens but in the meantime i wanted to note that using compile() instead of compile_for should work too now that we use embed-resource since it only compiles the resource for binaries if there is a mix of bins and libs in the project.

@FabianLars FabianLars added the bug Something isn't working label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants