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

Jos*_*llo 6 c# msbuild visual-studio-2010 envdte vsix

我正在使用Visual Studio 2010扩展,我想将属性添加到MSBuild项,如下所示:

 <EmbeddedResource Include="SomeFile.xml">
      <FooAttribute>%(Filename)%(Extension)</FooAttribute>
 </EmbeddedResource>
Run Code Online (Sandbox Code Playgroud)

所以,我发现的唯一方法是使用该方法IVsBuildPropertyStorage.SetItemAttribute.这适用于简单的字符串,但是当我尝试使用MSBuild特有的字符时,我得到了这个结果:

 <EmbeddedResource Include="SomeFile.xml">
      <FooAttribute>%29%25%28Filename%29%25%28Extension%29</FooAttribute>
 </EmbeddedResource>
Run Code Online (Sandbox Code Playgroud)

这意味着SetItemAttribute自动从MsBuild字符中逃脱,我不希望这样.

Ert*_*maa 2

这个问题有点老了,但需要一个答案。VS2010似乎有更好的界面,可以设置值而不转义。

IVsBuildPropertyStorage2 接口

由项目系统实现,以提供对 MSBuild 属性系统的访问权限。与 IVsBuildPropertyStorage 相比,此接口在设置属性方面提供了更大的灵活性。它允许添加新的条件属性组并且不会转义值。

即函数SetPropertyValueExhttp://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsbuildpropertystorage2.setpropertyvalueex.aspx