wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
129 stars 24 forks source link

error LGHT0001: Failed to compare two elements in the array. #4563

Closed wixbot closed 4 years ago

wixbot commented 10 years ago

The linker on v4.0.2220.0 throws this error: light.exe(0,0): error LGHT0001: Failed to compare two elements in the array.

The bug did not exist in v4.0.2115.0.

Originally opened by mberchtold

wixbot commented 10 years ago

Please provide the exception stack that is provided with this error message. If you are building via MSBuild, the log file will have the stack information.

Originally posted by robmen AssignedTo set to robmen

wixbot commented 10 years ago

Exception Type: System.InvalidOperationException Stack Trace: at System.Array.SorterObjectArray.DepthLimitedQuickSort(Int32 left, Int32 right, Int32 depthLimit) at System.Array.Sort(Array keys, Array items, Int32 index, Int32 length, IComparer comparer) at System.Collections.ArrayList.Sort(Int32 index, Int32 count, IComparer comparer) at System.Collections.ArrayList.Sort() at WixToolset.Linker.Link(IEnumerable`1 inputs, OutputType expectedOutputType) at WixToolset.Tools.Light.Run() at WixToolset.Tools.Light.Execute(String[] args)

Originally posted by mberchtold

wixbot commented 10 years ago

Release changed from v4.x to v4.0

wixbot commented 9 years ago

I just wanted to report that this still happens with the latest 4.0 release: v4.0.2603.0

Originally posted by mberchtold

wixbot commented 9 years ago

This still happens in v4.0.2719.0

Originally posted by mberchtold

wixbot commented 9 years ago

Yes, and it'll very likely continue to repro until the bug is marked Resolved fixed.

Originally posted by robmen

wixbot commented 9 years ago

Is there anything I can do (aside from fixing the bug) to get this resolved?

Originally posted by mberchtold

wixbot commented 9 years ago

You could debug into the code and provide more detail about exactly what the issue is and what your .wxs code is doing to hit it. That's one step less than fixing the bug yourself but should make it significantly easier to design the fix.

At this point, it isn't exactly clear what is causing the issue.

Originally posted by robmen

wixbot commented 9 years ago

I have tracked down the problem. It happens when two components have a File element with a non unique Name attribute value and a long name in the value. Example:

<Component Id="Comp1">
<!-- < Windows 8.1 -->
<Condition>VersionNT &lt; 603</Condition>
<File Id="file.dll" Name="wrapperlong.dll" KeyPath="yes" Source="$(var.SourceDir)source.dll" />
</Component>

<Component Id="Comp2">
<!-- >= Windows 8.1 -->
<Condition>VersionNT &gt;= 603</Condition>
<!-- Note: Same destination filename as Comp1 but components are mutually exclusive -->
<File Id="fileWin81.dll" Name="wrapperlong.dll" KeyPath="yes" Source="$(var.SourceDir)sourcewin81.dll" />
</Component>

If the Name value contains a short name (<= 8 chars) the bug is not triggered. A workaround is to explicitly set the ShortName as following: <File Id="file.dll" Name="wrapperlong.dll" ShortName="wrap146" KeyPath="yes" Source="$(var.SourceDir)source.dll" />

So it seems the problem is related to the short name generation in combination with non unique Name values.

Originally posted by mberchtold

wixbot commented 9 years ago

The problem is here: File: https://github.com/wixtoolset/wix4/blob/develop/src/tools/wix/Linker.cs // sort the rows by DiskId fileRows.Sort();

The Sort happens if there are at least 2 files with the same short file name.

The problem is now that the IComparable implementation in the FileRow class has been comment out. File: https://github.com/wixtoolset/wix4/blob/develop/src/libs/WixToolset.Data/Rows/FileRow.cs public sealed class FileRow : Row //, IComparable

Hence these elements cannot be compared.

A temporary solution would be to stop sorting the ArrayList as it is only used for the error message.

Originally posted by mberchtold

wixbot commented 9 years ago

Please see the following pull request for the proposed fix: https://github.com/wixtoolset/wix4/pull/134

Originally posted by mberchtold

Gerolkae commented 8 years ago

Is this Still an Issue?

I'm getting the error with July 5 Wix 4.0

My Code is Ok I’ve updated the snippet

</Component>
          <Component Id="SilverMonkeyExt" Guid="{DEC333A0-7393-4097-AB77-A2847D121A3C}">
            <File Id="SilverMonkey" Source="$(var.SilverMonkey2.TargetDir)SilverMonkey.exe" KeyPath="no" Checksum="yes" />
        <ProgId Id='SilverMonkeys' Description='Bot information File' >
          <Extension Id='bini' ContentType='application/BotInformationFile'>
            <Verb Id='open' Command='Open' TargetFile='SilverMonkey' Argument='"%1"' />
          </Extension>
        </ProgId>
      </Component>

I'm using a harvest project in VS2015 that contains the SilverMonkey.exe

robmen commented 8 years ago

Yes, the issue is still Open so it is still needs to be fixed.

SonnyAD commented 8 years ago

What about the fix proposed by mberchtold? Or could we sort by the entire path of the file instead of short name? I'll try to clone the repo see if I can come up with a fix.

SonnyAD commented 8 years ago

What should I have to be able to rebuild entirely wix4? VS2013 with C# and C++ features? Anything more?

fourpastmidnight commented 7 years ago

This issue also occurs if you use pre-processor variables:

<Component Directory="MingwFolder:\bin\">
<?if $(sys.BUILDARCH)=x64?>
    <File Id="OpenSSLCurl" Source="mingw64\bin\curl.exe" />
<?else?>
    <File Id="OpenSSLCurl" Source="mingw32\bin\curl.exe" />
<?endif?>
</Component>
<Component Directory="MingwFolder:\bin\">
<?if $(sys.BUILDARCH)=x64?>
    <File Id="OpenSSLLibCurl" Source="mingw64\bin\libcurl-4.dll" />
<?else?>
    <File Id="OpenSSLLibCurl" Source="mingw32\bin\libcurl-4.dll" />
<?endif?>
</Component>

I would've expected pre-processing to already have occurred, removing the unused XML (or, more accurately, ignoring the "duplicate" entry). In any event, for me at least, I simplified the above WiX XML and this is not a blocking issue for me. But just wanted to report my own findings.

robmen commented 4 years ago

This code is being reimplemented completely differently in issue https://github.com/wixtoolset/issues/issues/6212

RajagurunathanManikandan commented 2 years ago

Hi @robmen , @Gerolkae , @fourpastmidnight , @wixbot , @SonnyAD

I'm still facing this issue in the below versions.

error snap: image

Can you share the V4.0 download link which doesn't have this issue? Thanks in advance.

RajagurunathanManikandan commented 2 years ago

Hi @robmen , I guess this issue is not fixed, can you share the stable V4 version download link? Thanks in advance...

robmen commented 2 years ago

It's fixed in v4-preview.0. Get that from NuGet.

RajagurunathanManikandan commented 2 years ago

It's fixed in v4-preview.0. Get that from NuGet.

@robmen, @barnson, @rseanhall

Is there any option to build and generate msi from wix v4 project using wix dotnet tool? Or should I wait till wix v4 supports MSBuild?

Thanks in advance.

RajagurunathanManikandan commented 2 years ago

@robmen, @barnson, @rseanhall

Is there any option to build and generate msi from wix v4 project using wix dotnet tool? Or should I wait till wix v4 supports MSBuild?

Thanks in advance.

barnson commented 2 years ago

https://robmensching.com/blog/posts/2021/5/17/wix-toolset-v4-preview.0/