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

Installers seems stop working #1487

Closed
ValeriyLappo opened this issue Apr 2, 2024 · 15 comments
Closed

Installers seems stop working #1487

ValeriyLappo opened this issue Apr 2, 2024 · 15 comments

Comments

@ValeriyLappo
Copy link

My team and I make installers for our applications using your library, here is the code that is used in any our solution. I extracted most of the logic in test project with simple consoleApp (i can't provide .rar with all code)

using System;
using System.Collections.Generic;
using System.IO;
using WixSharp;

namespace Installer;

internal static class Installer
{
	public static void Main(string[] args)
	{
		var projectPath = @"C:\Users\Администратор\Desktop\Test\ConsoleApp1";
		Version version = new Version("1.0.0.0");

		var project = new ManagedProject
		{
			OutDir = "output",
			OutFileName = $"TestProject_{version}",
			InstallScope = InstallScope.perMachine,
			Name = "TestProject",
			GUID = Guid.NewGuid(),
			Platform = Platform.x64,
			UI = WUI.WixUI_ProgressOnly,
			Version = version,
			MajorUpgrade = new MajorUpgrade
			{
				AllowSameVersionUpgrades = true,
				DowngradeErrorMessage =
					$"A newer version of TestProject is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features.",
			},
			ControlPanelInfo =
			{
				Manufacturer = "Manufacturer",
				Contact = "Email"
			}
		};

		var directories = Directory.GetDirectories(projectPath, "bin/Release*", SearchOption.AllDirectories);
		if (directories.Length == 0) throw new Exception("No files were found to create an installer");

		var installDir = @"C:\Users\Public\TestProjectHome";
		List<Dir> dirs = new List<Dir>();
		foreach (var releaseDir in directories)
		{
			dirs.Add(new(installDir, new Files(@$"{releaseDir}\*.*", s => !s.EndsWithAny(false, ".pdb", ".config"))));
		}
		project.Dirs = dirs.ToArray();
		project.ResolveWildCards();

		project.BuildMsi();
	}
}

Yesterday some of one our users started to face with problem that installer seems doesn't work. Moreover, it is installed on some computers without problems, but it is not installed on others.

The main 100% workaround solution is run the msi installer with "Troubleshoot compatibility" from windows context menu.
But it's interesting why installers stopped works, because in Friday everything was fine, today with the same code we got such problem.

This is logs from other program being installer before troubleshooting logBefore.txt(failed) and after logAfter.txt (successfully installed)

Thank you for some suggestions why it happens

@ValeriyLappo
Copy link
Author

ValeriyLappo commented Apr 2, 2024

It seems like these guys facing the same problem as we, wixtoolset/issues#8078.

We also have such error messages in logs (see logBefore)

Maybe it's not your issue 😅

@oleg-shilo
Copy link
Owner

oleg-shilo commented Apr 3, 2024

Oh no, it's not WixSharp issue at all. This is 100% a WiX release/distribution problem.
....

My bad, I was responding to a different issue....

Nevertheless it is indeed a WiX problem, which is not necessarily caused by the WiX runtime. It looks like they did not anticipate that when they unpack managed-CA dll the process may not have enough privileges. This new behavior may have been introduced by a Win update or something...

@dosymep
Copy link

dosymep commented Apr 8, 2024

After update wix to version 5.0.0 I got exception System.IO.FileLoadException

Project ferefences:

  • Caliburn.Micro (4.0.212)
  • Caliburn.Micro.Core (4.0.212)
  • Newtonsoft.Json (13.0.3)
  • WixSharp_wix4 (2.1.5)
  • WixSharp_wix4.bin
(2.1.5")
  • WixSharp-wix4.WPF (2.1.5)
  • WixToolset.Dtf.WindowsInstaller (5.0.0)
  • WixToolset.Mba.Core (4.0.5)

Full error text:

Error : Unexpected error : System.IO.FileLoadException: Cannot resolve dependency to assembly 'WixToolset.Dtf.WindowsInstaller, Version=4.0.0.0, Culture=neutral, PublicKeyToken=a7d136314861246c' because it has not been preloade
d. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event. [E:\Projects\Code\Autodesk\Bim4EveryoneSetup\src\BIM4EveryoneSetup\BIM4Everyone
Setup.csproj]
     at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
     at System.Reflection.RuntimeAssembly.GetExportedTypes()
     at WixToolset.Dtf.MakeSfxCA.MakeSfxCA.FindEntryPoints(String module) in D:\a\wix\wix\src\dtf\WixToolset.Dtf.MakeSfxCA\MakeSfxCA.cs:line 416
     at WixToolset.Dtf.MakeSfxCA.MakeSfxCA.Build(String output, String sfxDll, IList`1 inputs, TextWriter log) in D:\a\wix\wix\src\dtf\WixToolset.Dtf.MakeSfxCA\MakeSfxCA.cs:line 192
     at WixToolset.Dtf.MakeSfxCA.MakeSfxCA.Main(String[] args) in D:\a\wix\wix\src\dtf\WixToolset.Dtf.MakeSfxCA\MakeSfxCA.cs:line 87

  ?????????????? ??????????: System.ApplicationException: Cannot package ManagedCA assembly(E:\Projects\Code\Autodesk\Bim4EveryoneSetup\src\BIM4EveryoneSetup\bin\x64\Debug\net48\WixSharp.dll)
     ? WixSharp.Compiler.PackageManagedAsm(String asm, String nativeDll, String[] refAssemblies, String outDir, String configFilePath, Nullable`1 platform, Boolean embeddedUI, String batchFile)
     ? WixSharp.Compiler.ProcessCustomActions(Project wProject, XElement product)
     ? WixSharp.Compiler.GenerateWixProj(Project project)
     ? WixSharp.Compiler.BuildWxs(Project project, String path, OutputType type)
     ? WixSharp.Compiler.BuildWxs(Project project, OutputType type)
     ? WixSharp.Compiler.Build(Project project, String path, OutputType type)
     ? WixSharp.Compiler.Build(Project project, OutputType type)
     ? WixSharp.Project.BuildMsi(String path)

@oleg-shilo
Copy link
Owner

WixSharp is integrated with wix4 and has not been tested with WiX 5. It may or may not work.

So far my experience with new WiX releases had a mixed success rate. So I usually wait until WiX major upgrades mature enough to be integrated.

My first look at wix5 changes confirmed that they are pure WiX changes and all their new MSI authoring experiences have already been implemented in WixSharp anyway. Thus at some point, I will update the wix5 integration but only just to allow using wix5 compilers. I will be handling this task under the normal priority and within the scope of the dedicated #1493.

However, if you see some valuable wix5 dev experience that is not available in WixSharp then let me know and I will bump the priority of #1493.

@dosymep
Copy link

dosymep commented Apr 8, 2024

I can’t build the old version of the installer with version 4.0.4 without error 1603. Сan you help with the problem?
telegram-cloud-photo-size-2-5212973258410940124-y

@oleg-shilo
Copy link
Owner

oleg-shilo commented Apr 8, 2024

You can build. Your post above indicates that you built your MSI. You have a runtime problem, that, I am speculating, is related to some configuration specifics of your target system. I could be wrong so you can prepare a simple hello-world project that exhibits this problem and I can have a look at it.

Switching to wix5 will most likely yield the same problem you are experiencing right now.

@dosymep
Copy link

dosymep commented Apr 8, 2024

installed wix

Package Id                      Version         Commands         
-----------------------------------------------------------------
wix                             4.0.4           wix              

Program.cs:

ManagedProject project = new ManagedProject("WixSharpTests");
project.AddDir(new Dir($"%AppDataFolder%/WixSharpTests",
	new Dir("WixSharpTests", new Files(Path.Combine("../", "*.*")))));

project.UI = WUI.WixUI_FeatureTree;
project.Codepage = "1251";
project.Language = "ru-RU";
project.Encoding = Encoding.UTF8;
project.Platform = Platform.x64;
project.Scope = InstallScope.perUser;

project.BuildMsi();

csproj:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net48</TargetFramework>
        <LangVersion>7.3</LangVersion>
    </PropertyGroup>

    <ItemGroup>
        <None Remove="*.msi" />
        <None Remove="*.exe" />
        <None Remove="*.wxs" />
        <None Remove="*.wixpdb" />
        <None Remove="*.wixobj" />
        <None Remove="CustomAction.config" />
        <Content Include="../../assets/*.*" Link="assets/%(FileName)$(FileExt)" />
        <Content Include="../../.github/workflows/*.yml" Link="ci/%(FileName)$(FileExt)" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Caliburn.Micro" Version="4.0.212" />
        <PackageReference Include="Caliburn.Micro.Core" Version="4.0.212" />
        <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
        <PackageReference Include="WixSharp_wix4" Version="2.1.5" />
        <PackageReference Include="WixSharp_wix4.bin" Version="2.1.5" />
        <PackageReference Include="WixSharp-wix4.WPF" Version="2.1.5" />
        <PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.4" />
        <PackageReference Include="WixToolset.Mba.Core" Version="4.0.4" />
    </ItemGroup>

    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
        <Exec Command="cd .\
        set ide=true;
        $(TargetPath);" />
    </Target>
</Project>

@oleg-shilo
Copy link
Owner

I do not know where wix v4.0.4 is coming from as it is not available on nuget.org:

image

I have updated my wix globally to v4.0.5 and rebuilt your sample. It runs as expected. I have attached the working sample for you to test. I suggest you build it in your environment and see if it behaves the same way:

image

WixSharp Setup4.zip

@oleg-shilo
Copy link
Owner

One more thing... don't forget, you have to run your msi elevated. If you don't then it may lead to exactly that type of problem as you described. Though, in this case MSI UI is very clear about insufficient privileges. But if you run without UI then .... you may only have that log entry and no other info.

@dosymep
Copy link

dosymep commented Apr 10, 2024

I just need to use the installation without elevated rights, my files are installed in the user's folder

@dosymep
Copy link

dosymep commented Apr 10, 2024

Before version 4.0.5 this installer worked without elevation

@oleg-shilo
Copy link
Owner

Sorry, I cannot comment on that. If indeed the previous version of WiX4 yielded different behaviour then you will need to contact the WiX team. However, I just retested the same sample I shared and it does not ask for the elevation. Even though I was under the impression it did when I tested it the first time. Thus I am not sure the problem exists. You will need to recheck...

Anyway, if you are to contact the WiX team then I suggest you create a test case by calling project.BuldMsiCmd(). This will produce a batch file that uses only WiX tools for building msi. From my experience, you will have more chances to get help if your test case is strictly about pure WiX.

@dosymep
Copy link

dosymep commented Apr 10, 2024

okay thanks.
We found a problem in the installer.
I wrote the installation path incorrectly - was %AppDataFolder% became %AppData%

@ValeriyLappo
Copy link
Author

Our problem seems to get solved when we changed nuget from WixSharp.bin
image
to WixSharp_wix4.bin
image

@oleg-shilo
Copy link
Owner

Just so you are aware:

  • WixSharp.bin targets WiX3 toolset, which you will need to install the toolset manually or with the WixSharp.wix.bin package.

  • WixSharp_wix4.bin targets WiX4 toolset. You will need to install the toolset with dotnet tool install --global wix.

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

No branches or pull requests

3 participants