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

How do I add DLLs to a package? #271

Open
nazar-pc opened this issue Dec 5, 2023 · 2 comments
Open

How do I add DLLs to a package? #271

nazar-pc opened this issue Dec 5, 2023 · 2 comments
Assignees
Labels

Comments

@nazar-pc
Copy link

nazar-pc commented Dec 5, 2023

There are #161 and #140, but they are not really that helpful, everyone is so cryptic about how to actually do it that I wasn't able to get it to work after spending hours.

What I have is an app that depends on GTK4. So I copied all DLLs into a separate directory target\gtk4, ran this command to get gtk4.wxs:

heat.exe dir target\gtk4 -gg -sfrag -template:fragment -out target\gtk4\gtk4.wxs -cg GTK -dr GTK

And then did cargo wix --include .\target\gtk4\gtk4.wxs and... nothing happened, meaning no DLLs were included, size of the msi file is the same, zero errors with --nocapture either.

So the question still remains: how do I add DLLs to a package? I'd really appreciate some help since I'm thankfully not dealing with Windows almost at all and unfortunately have no experience with such tools.

@volks73
Copy link
Owner

volks73 commented Dec 5, 2023

Do you have a large number of DLLs? If it is less than a handful or some reasonable number to manually manage, then the heat.exe utility is not needed, but each DLL will need to be explicitly defined in the WXS file.

Did you try the XML code in my comment here?

After executing the cargo wix init command, there should be a wix\main.wxs file in your project's source directory. Open the wix\main.wxs file in your favorite text editor and add this XML snippet from my comment in the appropriate location in the main.wxs file:

<!-- ... --->
<Directory Id='TARGETDIR' Name='SourceDir'>
    <Directory Id='$(var.PlatformProgramFilesFolder)' Name='PFiles'>
        <Directory Id='APPLICATIONFOLDER' Name='project-name'>
            <!-- In the most basic form, you can place the DLLs in the same
                 folder as the EXE; otherwise, put them in another folder. I just don't know the
                 DLL loading process for Rust EXEs. The DLLs may need to be in the same folder. -->
            <Directory Id='Bin' Name='bin'>
                <!-- ... --->
                <!-- Repeat the next <component> block for each DLL making sure
                     the `Source` attribute is the path to the DLL and you change the ID 
                     and Name accordingly. -->
                <Component Id='gtk4' Guid='*' Win64='$(var.Win64)'>
                    <File
                        Id='gtk4Dll'
                        Name='gtk4.dll'
                        DiskId='1'
                        Source='target\gtk4\gtk4.dll'
                        KeyPath='yes'/>
                </Component>
                <!-- ... --->
            </Directory>
        </Directory>
    </Directory>
</Directory>
<!-- ... --->

Can you provide a layout of your project structure and your wix\main.wxs file?

I would recommend placing the DLLs in some location under your project structure, like a lib, libs, or dlls directory instead of the target directory. You will have to change the Source attribute in the above XML to match the location, but the target directory is for build artifacts and output by convention.

@nazar-pc
Copy link
Author

nazar-pc commented Dec 5, 2023

Do you have a large number of DLLs? If it is less than a handful or some reasonable number to manually manage, then the heat.exe utility is not needed, but each DLL will need to be explicitly defined in the WXS file.

There is 42 files right now and since they come from GTK4 that is evolving I have no guarantees set of files or their names will remain constant.

Did you try the XML code in #76 (comment)?

Not yet, I was looking for an automated way to not list all the files explicitly due to above mentioned reasons.

Can you provide a layout of your project structure and your wix\main.wxs file?

https://github.com/nazar-pc/space-acres/blob/77f6f1f1869e48b32d1d9be100681db06c2cd745/wix/space-acres.wxs

I would recommend placing the DLLs in some location under your project structure, like a lib, libs, or dlls directory instead of the target directory. You will have to change the Source attribute in the above XML to match the location, but the target directory is for build artifacts and output by convention.

Since I primarily want to do packaging in CI I create target/gtk4 and copy files there, so it is in fact an output for me, it is not in Git for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants