如何从 Wix 中的新命名空间添加属性和元素并被 Wix 忽略?

发布于 2024-08-13 08:38:05 字数 296 浏览 2 评论 0原文

我想在 Wix wxs 文件中添加一个不相关的属性并希望 Wix 忽略它。

目前,它在寻找扩展名时会抛出以下错误。

Component 元素包含未处理的扩展属性“myns:myattr”。请确保“http://tempuri.org/myschema.xsd”中属性的扩展名命名空间已提供。

Rob、Bob 或 wix 团队中的任何人都在听!!:)

I want to add a unrelated attribute in the Wix wxs file and want Wix to ignore it.

It currently throws up following error as it goes looking for the extension.

The Component element contains an unhandled extension attribute 'myns:myattr'. Please ensure that the extension for attributes in the 'http://tempuri.org/myschema.xsd' namespace has been provided.

Rob, Bob or anybody on wix team listening!!:)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

高跟鞋的旋律 2024-08-20 08:38:05

编写一个wix扩展来处理该XML命名空间中的元素。以下示例扩展将导致命名空间 http://www.example.com 中的任何元素被忽略:

将以下代码保存在 mywixext.cs 中:

using System.Xml.Schema;
using Microsoft.Tools.WindowsInstallerXml;
using System.Xml;

[assembly: AssemblyDefaultWixExtension(
   typeof(mywixext.IgnoreNamespaceWixExtension))]

namespace mywixext
{

   public class IgnoreNamespaceWixExtension : WixExtension
   {
      public override CompilerExtension CompilerExtension
      {
         get
         {
            return new IgnoreNamespaceCompilerExtension();
         }
      }
   }

   public class IgnoreNamespaceCompilerExtension : CompilerExtension
   {
      public override XmlSchema Schema
      {
         get
         {
            return new XmlSchema() 
            {
               TargetNamespace = "http://www.example.com" 
            };
         }
      }

      public override void ParseElement(
         SourceLineNumberCollection sourceLineNumbers,
         XmlElement parentElement, XmlElement element,
         params string[] contextValues)
      {
         // do nothing
      }

   }
}

现在编译它到 mywixext.dll 中,如下所示:

"c:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe" /t:library ^
/r:"c:\program files\windows installer xml v3\bin\wix.dll" ^
mywixext.cs

如果您现在使用选项 -ext mywixext.dll 编译 wix 源代码(或在 votive 中执行等效操作),则 < code>http://www.example.com 命名空间将被忽略。

编辑:当我说任何元素都会被忽略时,我是不精确的。 WIX XML 架构不允许您直接在 WIX 元素下添加自己的子元素。大多数其他元素都允许这样做。在 c:\program files\windows installer xml v3\doc\wix.xsd 中查找文本 来查找扩展点。

Write a wix extension which handles elements in that XML namespace. The following example extension will cause any elements in the namespace http://www.example.com to be ignored:

Save the following code in mywixext.cs:

using System.Xml.Schema;
using Microsoft.Tools.WindowsInstallerXml;
using System.Xml;

[assembly: AssemblyDefaultWixExtension(
   typeof(mywixext.IgnoreNamespaceWixExtension))]

namespace mywixext
{

   public class IgnoreNamespaceWixExtension : WixExtension
   {
      public override CompilerExtension CompilerExtension
      {
         get
         {
            return new IgnoreNamespaceCompilerExtension();
         }
      }
   }

   public class IgnoreNamespaceCompilerExtension : CompilerExtension
   {
      public override XmlSchema Schema
      {
         get
         {
            return new XmlSchema() 
            {
               TargetNamespace = "http://www.example.com" 
            };
         }
      }

      public override void ParseElement(
         SourceLineNumberCollection sourceLineNumbers,
         XmlElement parentElement, XmlElement element,
         params string[] contextValues)
      {
         // do nothing
      }

   }
}

Now compile it into mywixext.dll like this:

"c:\WINDOWS\Microsoft.NET\Framework\v3.5\csc.exe" /t:library ^
/r:"c:\program files\windows installer xml v3\bin\wix.dll" ^
mywixext.cs

If you now compile your wix sources with the option -ext mywixext.dll (or do the equivalent in votive) then all elements in the http://www.example.com namespace will be ignored.

edit: I was imprecise when I said that any element would be ignored. The WIX XML schema does not allow you to add your own child elements directly under the WIX element. Most other elements allow it. Look for the text <xs:any namespace="##other" processContents="lax"> in c:\program files\windows installer xml v3\doc\wix.xsd to find the extensibility points.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文