3

To start with, I am new to WixSharp. For several hours now I have been trying to specify a custom file, License.rtf, for my setup project like this:

project.LicenceFile = "License.rtf";

But I keep getting this error:

C# Script execution engine. Version 3.9.4.1.
Copyright (C) 2004-2014 Oleg Shilo.

Error: Specified file could not be executed.

System.Xml.XmlException: The prefix '' cannot be redefined from 'http://schemas. microsoft.com/wix/2006/wi' to '' within the same start element tag.
at System.Xml.XmlWellFormedWriter.PushNamespaceExplicit(String prefix, String ns)
at System.Xml.XmlWellFormedWriter.WriteEndAttribute()
at System.Xml.Linq.ElementWriter.WriteStartElement(XElement e)
at System.Xml.Linq.ElementWriter.WriteElement(XElement e)
at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
at System.Xml.Linq.XContainer.WriteContentTo(XmlWriter writer)
at System.Xml.Linq.XDocument.WriteTo(XmlWriter writer)
at System.Xml.Linq.XDocument.Save(TextWriter textWriter, SaveOptions options)

at WixSharp.Compiler.BuildWxs(Project project, String path, OutputType type)
at WixSharp.Compiler.BuildWxs(Project project, OutputType type)
at WixSharp.Compiler.Build(Project project, String path, OutputType type)
at WixSharp.Compiler.Build(Project project, OutputType type)
at Script.Main(String[] args)

Please can someone tell me what I am doing wrong. Here is my setup.cs code:

//css_dir ..\..\;
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;
//css_ref System.Core.dll;
using System;
using System.Xml;
using System.Xml.Linq;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;
using WixSharp;
using WixSharp.CommonTasks;

class Script
{
static public void Main(string[] args)
{
    var project =

        new Project("myproduct",
            new Dir(@"%ProgramFiles%\My Company\myproduct", new DirFiles(@"Files\*.*"), 
        new Dir("DataModel", new DirFiles(@"Files\Data\*.*"),new Dir("Music", new DirFiles(@"Files\Data\Music\*.*")),new Dir("CardPack", new DirFiles(@"Files\Data\CardPack\*.*")),new Dir("CardSingle", new DirFiles(@"Files\Data\CardSingle\*.*"))),
                    new ExeFileShortcut("Uninstall MyProduct", "[System64Folder]msiexec.exe", "/x [ProductCode]")), 
    new Dir(@"%AppDataFolder%\myproduct", new File(@"Files\Config\Configure.json"), new Dir("Folder1", new DirFiles(@"Files\Folder2\*.*"))));
    project.LicenceFile = "License.rtf";
    project.UI = WUI.WixUI_Minimal;
    project.GUID = new Guid();

    project.ResolveWildCards();

    var exeFile = project.AllFiles.Single(f=>f.Name.EndsWith("myproduct.exe"));

    exeFile.Shortcuts = new[] { 
                                new FileShortcut("myproduct.exe", "INSTALLDIR"),
                                new FileShortcut("myproduct.exe", @"%Desktop%")
                              };

    Compiler.BuildMsi(project);
}
}

Thanks in advance.

Jimmy
  • 41
  • 5

1 Answers1

0

Not sure if you found an answer to your question, but Orca is an MSI Table editor that is included in the Windows SDK.

For Windows 7 and .NET 3.5 SP1 - https://www.microsoft.com/en-us/download/confirmation.aspx?id=3138

Once installed, navigate to C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin and execute the orca.msi. You will then run your Wix# project to generate the msi file. Open the msi file with Orca and navigate to the Binary table. Double click on the data column for WixSharp_LicenseFile and you will be given an option to read or write to a file. If you want to see the contents, select a file name (.rtf format) and write to file. Make any changes you wish, or replace that file, and then use it to read into that binary data row. Once you have read it into the msi table, save the msi file and close.

I am new to WixSharp myself, so I have not found another way (yet!), but this worked for me.

Good luck!

Jim
  • 1
  • 1