diff --git a/src/AddIns/BackendBindings/WixBinding/Project/Src/WixBinaries.cs b/src/AddIns/BackendBindings/WixBinding/Project/Src/WixBinaries.cs
index 485d78dbb3..9d44bc4acb 100644
--- a/src/AddIns/BackendBindings/WixBinding/Project/Src/WixBinaries.cs
+++ b/src/AddIns/BackendBindings/WixBinding/Project/Src/WixBinaries.cs
@@ -99,7 +99,9 @@ namespace ICSharpCode.WixBinding
document.Load(textFileReader.Create(fileName));
document.FileName = fileName;
foreach (WixBinaryElement element in document.GetBinaries()) {
- binaries.Add(element.Id, element.FileName);
+ if (!binaries.ContainsKey(element.Id)) {
+ binaries.Add(element.Id, element.FileName);
+ }
}
} catch (FileNotFoundException) {
} catch (XmlException) {
diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs b/src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs
new file mode 100644
index 0000000000..5a718d116c
--- /dev/null
+++ b/src/AddIns/BackendBindings/WixBinding/Test/Document/DuplicateBinaryIdTestFixture.cs
@@ -0,0 +1,92 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using ICSharpCode.WixBinding;
+using ICSharpCode.SharpDevelop.Project;
+using NUnit.Framework;
+using System;
+using System.Drawing;
+using System.Collections.Generic;
+using System.IO;
+using WixBinding.Tests.Utils;
+
+namespace WixBinding.Tests.Document
+{
+ ///
+ /// Tests that WixBinaries class does not try to add the same binary id to the hash table.
+ ///
+ [TestFixture]
+ public class DuplicateBinaryIdTestFixture : ITextFileReader
+ {
+ WixBinaries binaries;
+ string projectDirectory;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ WixProject p = WixBindingTestsHelper.CreateEmptyWixProject();
+ projectDirectory = p.Directory;
+ p.Name = "MySetup";
+
+ FileProjectItem item = new FileProjectItem(p, ItemType.Compile);
+ item.Include = "Setup.wxs";
+ string docFileName = item.FileName;
+ ProjectService.AddProjectItem(p, item);
+
+ item = new FileProjectItem(p, ItemType.Compile);
+ item.Include = "Binaries.wxs";
+ ProjectService.AddProjectItem(p, item);
+
+ WixDocument doc = new WixDocument(p);
+ doc.FileName = docFileName;
+ doc.LoadXml(GetMainWixXml());
+
+ binaries = new WixBinaries(doc, this);
+ }
+
+
+ [Test]
+ public void GetDialogBitmapFileName()
+ {
+ string expectedFileName = Path.Combine(projectDirectory, "Bitmaps/Dialog.bmp");
+ Assert.AreEqual(expectedFileName, binaries.GetBinaryFileName("Dialog"));
+ }
+
+
+ public TextReader Create(string fileName)
+ {
+ fileName = Path.GetFileName(fileName);
+ if (fileName == "Binaries.wxs") {
+ return new StringReader(GetWixFragmentXml());
+ }
+ return new StringReader(GetMainWixXml());
+ }
+
+ string GetMainWixXml()
+ {
+ return "\r\n" +
+ "\t\r\n" +
+ "\t\t\r\n" +
+ "\t\r\n" +
+ "";
+ }
+
+ string GetWixFragmentXml()
+ {
+ return "\r\n" +
+ "\t\r\n" +
+ "\t\t\r\n" +
+ "\t\t\r\n" +
+ "\t\r\n" +
+ "";
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj b/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj
index 6b8e1ffac1..34f9722c90 100644
--- a/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/WixBinding/Test/WixBinding.Tests.csproj
@@ -50,6 +50,7 @@
+