Setup exe for running on different computer

can anyone help me with setup i have downloaded to source code and run the project by adding Duplicati.GUI.TrayIcon as the startup project

it creates exe in debug files

when i try to run that exe in different pc for installing the app it crashes with following error

Duplicati.Library.Interface.UserInformationException: Server crashed on startup
—> System.IO.IOException: The process cannot access the file ‘C:\Users\Bhavesh pc\Desktop\Duplicati__net8.0\Duplicati-trayicon.debug.log’ because it is being used by another process.
at System.IO.FileSystem.DeleteFile(String fullPath)
at Duplicati.Server.Program.ConfigureLogging(Dictionary2 commandlineOptions) in D:\SampleProject\Github_Repository\duplicati-master\Duplicati\Server\Program.cs:line 640 at Duplicati.Server.Program.Main(String[] _args) in D:\SampleProject\Github_Repository\duplicati-master\Duplicati\Server\Program.cs:line 255 at Duplicati.GUI.TrayIcon.HostedInstanceKeeper.<>c__DisplayClass5_0.<.ctor>b__0(Object dummy_arg) in D:\SampleProject\Github_Repository\duplicati-master\Duplicati\GUI\Duplicati.GUI.TrayIcon\HostedInstanceKeeper.cs:line 49 --- End of inner exception stack trace --- at Duplicati.GUI.TrayIcon.HostedInstanceKeeper..ctor(String[] args) in D:\SampleProject\Github_Repository\duplicati-master\Duplicati\GUI\Duplicati.GUI.TrayIcon\HostedInstanceKeeper.cs:line 83 at Duplicati.GUI.TrayIcon.Program.Main(String[] _args) in D:\SampleProject\Github_Repository\duplicati-master\Duplicati\GUI\Duplicati.GUI.TrayIcon\Program.cs:line 127 at Duplicati.GUI.TrayIcon.Net8.Program.<>c__DisplayClass0_0.<Main>b__0() in D:\SampleProject\Github_Repository\duplicati-master\Executables\net8\Duplicati.GUI.TrayIcon\Program.cs:line 9 at Duplicati.Library.Crashlog.CrashlogHelper.WrapWithCrashLog[T](Func1 method, String logdir, String applicationName) in D:\SampleProject\Github_Repository\duplicati-master\Duplicati\Library\Crashlog\CrashlogHelper.cs:line 62

Hi @Bhavesh_Shirwadkar, welcome to the forum.

I think this is what you need to figure out:

What other process is accessing that file? There should be no other process accessing that file, so it is either a permission error (hiding with a wrong error message) or you have more than one instance running.

A side-note: it is not good practice to ship binaries built in debug mode. You can use the dotnet publish command to get a release build:

dotnet publish -c Release

Using a release build will not create the debug log file.

Thanks @kenkendk had successfully executed it,

Can you help with guiding for building msi setup file.

If you build it on Windows, you can use WiX Toolset. If you build it on MacOS/Linux you need wixl from msitools. You need to build it from source and add these two patches that are not yet merged:

Once you have either WiX or wixl ready, you can use the ReleaseBuilder tool that is also used to build Duplicati releases.

I have not used the tool on Windows, so there might be some rough edges.

Hi @kenkendk
After searching alot, I found this article to build MSI using ResourceBuilder Tool.

I am getting error on windows while building the application.

As mentioned in the documentation, I did install wix toolset latest version and also have node installed. I am running in visual studio 2022.

Could you please help on this or do you have any doc ?

Thanks in advance.

You can set the path to npm via the environment variable NPM=<path to npm.exe>.
You can usually configure this in launch.json.

You can also debug it in EnvHelper.cs:81 where it uses FindCommand() to locate npm. It basically searches your PATH environment variable, and it appears this fails on your system.

Hi @kenkendk,
Thanks for quick response.

I have tried your approach but i am not sure why it is looking for

C:\Users\Admin\AppData\Roaming\npm\npm.exe

There is no such file exist into a folder when i did install nodejs and npm came along with nodejs only.

I am not sure we can install npm explicitly.

As highlighted in screenshot

And also i debug the code and that path have multiple items

Really appreciate your time.

Thanks in advance.

I don’t know the logic behind putting executables in %APPDATA% but it seems messy and a security issue. But it should work fine.

I think it has been found correctly then, but looking for the wrong executable. The code is looking for npm.exe but it appears it is called npm.cmd on Windows.

I would try setting the NPM environment variable then:

NPM=C:\Users\Admin\AppData\Roaming\npm\npm.cmd

Note that NPM is only used to pull the newest version of the ngclient UI, so you could disable the npm stuff and just do npm i yourself.

Hi @kenkendk,

Your solution is worked very well for building zip files but unable to build MSI installer.

Usually i use this command to run: dotnet run build canary --version 1.0.0.2 --disable-docker-push true --keep-builds true --disable-authenticode true --disable-signcode false --disable-notarize-signing true --disable-gpg-signing true --disable-s3-upload true --disable-github-upload true --disable-update-server-reload true --disable-discourse-announce true --targets win-x64-gui.msi

To fix npm command not found issue i have updated code.

When trying to build msi installer it some error on this line. I am new to wix toolset.

and also have installed wix.exe in correct path not sure whether its argument issue or not?

I stuck on this issue long hour not sure how i can fix this ?

Any help would be appreciated !!

The options --ext ui and --extdir <folder> are most likely wixl only.
Comment out lines 283 and 284 and it should progress.

Hi @kenkendk,

I did cleaned up my windows 10 system and freshly install wix v3 extension for visual studio community 2022 using vs2022 itself.
Explicitly also installed wix using dotnet command line.

dotnet tool install --global wix

This installs version wix version 5

I have cloned fresh duplicati repo from git, build successfully.
still i am getting error from last 2 days.


While running msi build and also i am not sure the issue with my system or not.
It is running till build package afterward its failed

Could you please help on this ?

I am unable to debug ReleaseBuilder project in visual studio 2022.

For legacy reasons, it looks like wix.exe does not use --define like most other programs, but instead uses -define (single hyphen). See wix.exe manual for more details.

If you use the current master branch, I updated with the previous problem you encountered, so it now looks like:

            List<string> wixArgs = [
                Program.Configuration.Commands.Wix!,
                "--define", $"HarvestPath={sourceFiles}",
                "--arch", msiArch,
                "--output", msiFile,
                Path.Combine(resourcesSubDir, "Shortcuts.wxs"),
                binFiles,
                Path.Combine(resourcesSubDir, "Duplicati.wxs")
            ];

And you need to change it to:

            List<string> wixArgs = [
                Program.Configuration.Commands.Wix!,
                "-define", $"HarvestPath={sourceFiles}",
                "-arch", msiArch,
                "-out", msiFile,
                Path.Combine(resourcesSubDir, "Shortcuts.wxs"),
                binFiles,
                Path.Combine(resourcesSubDir, "Duplicati.wxs")
            ];

Thanks @kenkendk for replying and appreciate your time to being active here !!

Yes i have also visited the wix.exe documentation [Wix.exe command-line reference]

Tried couple of ways to execute the process unfortunately no luck till now.

List<string> wixArgs = [
    Program.Configuration.Commands.Wix!,
    "-defined", $"HarvestPath={sourceFiles}",
    "-arch", msiArch,
    "-out", msiFile,
    Path.Combine(resourcesSubDir, "Shortcuts.wxs"),
    binFiles,
    Path.Combine(resourcesSubDir, "Duplicati.wxs")
];

Output:

List<string> wixArgs = [
    Program.Configuration.Commands.Wix!,
    "-d", $"HarvestPath={sourceFiles}",
    "-arch", msiArch,
    "-o", msiFile,
    Path.Combine(resourcesSubDir, "Shortcuts.wxs"),
    binFiles,
    Path.Combine(resourcesSubDir, "Duplicati.wxs")
];

Output:

Not sure why wix v5 command line behave inappropriately.

As mentioned in the document we use arguments like -d or define, -arch, -out or -o
none of these working so far.
I believe something is major changed on wix v5 toolset command line.

Also tried with manual execute command line using below

image

But it is also not working.

Arh, I did not catch that part, but you also need build (from manual):

wix build [options] source_file.wxs [source_file.wxs ...]

So it may be required to do:

List<string> wixArgs = [
                Program.Configuration.Commands.Wix!,
                "build",
                "-define", $"HarvestPath={sourceFiles}",
                "-arch", msiArch,
                "-out", msiFile,
                Path.Combine(resourcesSubDir, "Shortcuts.wxs"),
                binFiles,
                Path.Combine(resourcesSubDir, "Duplicati.wxs")
            ];

Above command is works correctly.
I have upgraded wix v3 to v4 for example:

1) duplicati\ReleaseBuilder\Resources\Windows\TrayIcon\Duplicati.wxs
2) duplicati\ReleaseBuilder\Resources\Windows\TrayIcon\Shortcuts.wxs

From: <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
To: <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">

There is duplicati\ReleaseBuilder\Resources\Windows\TrayIcon\binfiles.wxs file which is generated dynamically that have some errors state:

error WIX0014: The ComponentRef/@Id attribute's value, 'zh-Hant_System.CommandLine.resources.dll', is not a legal identifier. Identifiers may contain ASCII characters A-Z, a-z, digits, underscores (_), or periods (.). Every identifier must begin with either a letter or an underscore.

Need your attention please?

Ok, then there is (at least) one more character that needs to be fixed.
You can fix it in WixHeatBuilder.cs:41, and add the additional escape:

fileIdGenerator ??= (x) => Path.GetRelativePath(sourceFolder, x).Replace("\\", "_").Replace("/", "_").Replace(":", "_").Replace(" ", "_").Replace("-", "_")

FYI, I am making these changes in a PR:

You can see the change to the generator here, but I have also made an update that correctly handles the WiX identifier specification.