c# - 在wixsharp中为项目指定自定义许可文件

标签 c# wix wixsharp

首先,我是 WixSharp 的新手。几个小时以来,我一直在尝试为我的安装项目指定一个自定义文件 License.rtf,如下所示:

project.LicenceFile = "License.rtf";

但我一直收到这个错误:

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)

请有人告诉我我做错了什么。这是我的 setup.cs 代码:

//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);
}
}

提前致谢。

最佳答案

不确定您是否找到问题的答案,但 Orca 是 Windows SDK 中包含的 MSI 表编辑器。

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

安装后,导航至 C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin 并执行 orca.msi。然后,您将运行 Wix# 项目以生成 msi 文件。使用 Orca 打开 msi 文件并导航到二进制表。双击 WixSharp_LicenseFile 的数据列,您将看到读取或写入文件的选项。如果要查看内容,请选择文件名(.rtf 格式)并写入文件。进行您希望的任何更改,或替换该文件,然后使用它来读入该二进制数据行。将其读入 msi 表后,保存 msi 文件并关闭。

我自己是 WixSharp 的新手,所以我还没有找到另一种方法(还!),但这对我有用。

祝你好运!

关于c# - 在wixsharp中为项目指定自定义许可文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32795696/

相关文章:

c# - 如何使用WixSharp在ProgramFiles64Forder下安装多个子目录?

c# - 如何取消选择其他 AppBarToggleButton UWP

c# - 有人可以解释一下这个委托(delegate)语法吗?

c# - Signalr 将 IHubContext 转换为实际的 Hub

installation - WiX:将安装路径传递给托管自定义操作

wix - Majorupgrade 或 Upgrade ID 哪个是主要升级的首选?

installation - 如果已安装其他产品,如何使用 Wix 阻止安装

c# - WixSharp 注入(inject)多个自定义 CLR 对话框

c# - 在没有第 3 方库的情况下使用 C# .net 3.0 或更低版本将 pdf 转换为 tiff?