代码之家  ›  专栏  ›  技术社区  ›  José F. Romaniello

如何防止IVsBuildPropertyStorage.SetItemAttribute转义特殊字符?

  •  6
  • José F. Romaniello  · 技术社区  · 16 年前

     <EmbeddedResource Include="SomeFile.xml">
          <FooAttribute>%(Filename)%(Extension)</FooAttribute>
     </EmbeddedResource>
    

    到目前为止,我发现的唯一方法是使用 IVsBuildPropertyStorage.SetItemAttribute . 这对简单字符串很有用,但当我尝试使用MSBuild特有的字符时,会得到以下结果:

     <EmbeddedResource Include="SomeFile.xml">
          <FooAttribute>%29%25%28Filename%29%25%28Extension%29</FooAttribute>
     </EmbeddedResource>
    

    这意味着 SetItemAttribute

    1 回复  |  直到 16 年前
        1
  •  2
  •   Erti-Chris Eelmaa    12 年前

    这个问题有点老了,但需要一个答案。VS2010似乎有更好的接口,可以在不转义的情况下设置值。

    IVsBuildPropertyStorage2接口

    由项目系统实现,以提供对 关于设置IVsBuildPropertyStorage以外的属性。它允许 添加新的条件属性组和 无法逃脱 价值观。

    即功能 设置属性值 : http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsbuildpropertystorage2.setpropertyvalueex.aspx