-
Notifications
You must be signed in to change notification settings - Fork 179
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
Build fails when contents include certain C# System
DLLs
#1691
Comments
I will try to reproduce it. |
And if I can provide any more details or information to help, let me know |
OK, I quickly realized that I will succeed and always will if I include the same "system.dll" as the build script is running with. Can you please share with me a simple "hello-world" style sample that shows the problem? It will be enough for it to include those two problematic assemblies and to have the same deployment structure as yours. |
Here's a minimal project where I was able to reproduce the same errors I detailed: DllErrorExample.zip It includes copies of the same two |
Great, I can reproduce the problem now. |
WOW, you have discovered a .NET bug. A juicy one. First, I found that there is nothing wrong with your WixSharp project and you can even build the msi from the batch file The next break through came when I realize that even if I remove EVERYTHING from static main, the project still fails. Meaning that it is the project structure that is causing the problem. The next one... is a console app sample (attached). It has only one line implementation: using System;
using System.Collections.Generic;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
var ttt = new Queue<int>();
}
}
} And it fails from the moment you drop the Let me think about it. It's hard to "fix" .NET problem from the WixSharp code. |
OK, fortunately the WiX toolset has enough flexibility to trick the .NET build system. You will need to rename the offending files so the .NET builder is not upset. But in your wxs file you need to add an extra attribute Name to the File element. This attribute should be the file name as you want it to appear on the target system. Thus if you add a file to the project manually you should rename your // instead of this
// new File(@"Contents\System.dll"),
// use this
new File(@"Contents\_System.dll") { TargetFileName = "System.dll" }, But since you are using project.WixSourceGenerated += (doc) =>
{
doc.FindAll("File")
.Single(x => x.HasAttribute("Source", a => a.EndsWith("_System.dll")))
.SetAttribute("Name", "System.dll");
doc.FindAll("File")
.Single(x => x.HasAttribute("Source", a => a.EndsWith("_System.Windows.Forms.dll")))
.SetAttribute("Name", "System.Windows.Forms.dll");
}; I have attached the corrected working sample. DllErrorExample.zip And... I do recommend that you report the .NET bug. Having some files in the project structure (e.g. to be included as resources) should bot fail the build. |
Well, finding a .NET bug was not on my 2024 bingo card but I guess here we are! Thanks for figuring that out, I would never have solved that on my own! The XML injection solution you proposed worked wonders, and I was able to get my Unity program to install. Do you think this issue is worth adding some functionality to WixSharp to avoid in the future? Like some kind of prefix action to automatically rename As for reporting the bug, where do you think would be the most logical place to report it? |
Not exactly, but it's kinda already there. WixSharp allows you to have the file name on the target system different two what you have during the build: new File(@"Contents\_System.dll") { TargetFileName = "System.dll" }, If you want to have automated solution with wild cards (as in your your sample) then you can unpack the public static Files FromBuildDir(string buildDir, string fileExtensions = ".exe|.dll|.xml|.config|.json")
=> new Files(buildDir.PathJoin("*.*"),
f => f.EndsWithAny(true, fileExtensions.Split('|'))); And if you now use string fileExtensions = ".exe|.dll|.xml|.config|.json";
. . .
new Files(@"..\Release Folder\test\*.*", x => x.EndsWithAny(true, fileExtensions.Split('|'))")
{
OnProcess = file =>
{
file.TargetFileName = Path.GetFileName(file.Name).Replace("_System", "System");
}
}, |
Apologies if this is a known issue already, I checked for a duplicate to the best of my ability.
I'm trying to create an installer for an application I've built in the Unity game engine, but I'm running into an issue with certain
.dll
files being included in the contents of the installer. Built Unity games are packaged with all the.dll
files they need to run (e.g.MyGame/MyGame_Data/Managed/UnityEngine.dll
), and that includes a number of C# libraries that seem to be colliding with the libraries that WixSharp uses to create the.msi
installer, specificallySystem.dll
andSystem.Windows.Forms.dll
.System.Windows.Forms.dll
In the case of the
System.Windows.Forms.dll
file, the build completes with a warning, and the.msi
installer seems to work without issue. The gist of the issue seems to be these lines in the warning:Removing the
System.Windows.Forms.dll
file from the build directory resolves the issue. Here's the full error for completeness:System.Windows.Forms Error Output
System.dll
In the case of the
System.dll
file, however, the build fails completely, citing an issue of being unable to find theQueue<>
type name:This then leads to two cascading errors raised from the same
FeaturesDialog.xaml.cs
file:Removing the
System.dll
file from the build directory resolves the issue.Project Information
I used the WiX4 version of the Managed UI (WPF) template to create the installer, but set it to just use the default WPF dialogs when the errors began. I have WiX version
5.0.2
installed and WixSharp version2.4.3
installed (specifically:WixSharp-wix4.WPF 2.4.3
). Here's myProgram.cs
file for completeness:Program.cs
Any help or guidance is greatly appreciated.
The text was updated successfully, but these errors were encountered: