2015-09-26 144 views
1

首先,我是WixSharp的新手。對於幾個小時,現在我一直在試圖指定自定義文件,License.rtf,我的設置項目是這樣的:在wixsharp中指定項目的自定義許可證文件

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

在此先感謝。

回答

0

不確定您是否找到問題的答案,但Orca是包含在Windows SDK中的MSI表編輯器。

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

一旦安裝,瀏覽到C:\ Program Files文件\微軟的SDK \的Windows \ V7.0 \ BIN 並執行orca.msi。然後,您將運行Wix#項目來生成msi文件。使用Orca打開msi文件並導航到二進制表。雙擊WixSharp_LicenseFile的數據列,您將獲得讀取或寫入文件的選項。如果您想查看內容,請選擇文件名(.rtf格式)並寫入文件。根據需要進行任何更改,或者替換該文件,然後使用它讀入該二進制數據行。一旦你將它讀入msi表,保存msi文件並關閉。

我是WixSharp自己的新手,所以我還沒有找到另一種方式(但!),但這對我有效。

祝你好運!

相關問題