开发者

How do I prevent IVsBuildPropertyStorage.SetItemAttribute from escaping special characters?

开发者 https://www.devze.com 2023-01-20 23:30 出处:网络
I am working on a Visual Studio 2010 extension and I want to add an attribute to an MSBuild Item, as follows:

I am working on a Visual Studio 2010 extension and I want to add an attribute to an MSBuild Item, as follows:

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

So, far the only way I found is using the method IVsBuildPropertyStorage.SetItemAttribute . This works fine for simple strings, but when i try to use characters that are special to MSBuild, I get this result:

 <EmbeddedResource Include="SomeFile.xml">
      <FooAttribute>%29%25%28Filename%29%25%28Extension%29&开发者_StackOverflow中文版lt;/FooAttribute>
 </EmbeddedResource>

This means that SetItemAttribute automatically escapes from MsBuild characters and I don't want that.


This question is a bit old, but needs an answer. VS2010 seems to have better interface that can set values without escaping.

IVsBuildPropertyStorage2 Interface

Implemented by the project system to give flavors access to the MSBuild property system. This interface provides more flexibility around setting properties than IVsBuildPropertyStorage. It allows for adding a new conditional property group and does not escape the values.

Namely the function SetPropertyValueEx: http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.interop.ivsbuildpropertystorage2.setpropertyvalueex.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消