.NET Forum / Visual Studio.NET / Extensibility / April 2006
Controlling how items are added to IVsHierarchy and MSBuil in Flavored project
|
|
Thread rating:  |
Stuart Carnie - 30 Mar 2006 17:59 GMT Is it possible, when an item is added to the IVsHierarchy of my Flavored project, I can override the item type it is created as or do I have to use the Automation model and do it after it has been added?
Example, rather than my xml document being added to the project as
<ItemGroup> <None Include="my.myxml" /> </ItemGroup>
can I hook something, so it is automatically added with additional data as follows?
<ItemGroup> <MyXml Include="my.myxml"> <Data1>MyExtraData</Data1> </MyXml> </ItemGroup>
Cheers,
Stu
"Gary Chang[MSFT]" - 31 Mar 2006 08:59 GMT Hi Stuart,
>Is it possible, when an item is added to the IVsHierarchy >of my Flavored project, I can override the item type it is >created as or do I have to use the Automation model and >do it after it has been added? As we discussed before, the IVsBuildPropertyStorage::SetItemAttribute() method could do this task. But it may be some problems when you use it in the OnItemAdded event.
Currently, we are looking into this problem and will follow it in your previous newsgroup thread. If you have any other issues or concerns, please let me know. It's my pleasure to be of assistance.
Thanks for your understanding.
Best regards,
Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Stuart Carnie - 31 Mar 2006 16:43 GMT Gary Chang[MSFT] wrote:
> Hi Stuart, > [quoted text clipped - 28 lines] > ================================================== > This posting is provided "AS IS" with no warranties, and confers no rights. Actually, SetItemAttribute adds nested elements tot the item, whereas I want to specify the item itself, as describe in my original post, instead of:
<ItemGroup> <None Include="my.myxml" /> </ItemGroup>
I'd like to change "None" to something else, of my choice. e.g.
<ItemGroup> <MyXml Include="my.myxml" /> </ItemGroup>
Cheers and thanks for your assistance,
Stuart
"Gary Chang[MSFT]" - 03 Apr 2006 11:16 GMT Hi Stuart,
I have consulted this issue with our VSIP specialists, they suggest you can implement an automation project/project item externder to add extra properties and filtering.
Another approach you can try is using the IVsHierarchy::SetProperty with VSHPROPID_ItemSubType, have you tried to set that value?
Thanks!
Best regards,
Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Stuart Carnie - 03 Apr 2006 16:46 GMT Gary Chang[MSFT] wrote:
> Hi Stuart, > [quoted text clipped - 22 lines] > ================================================== > This posting is provided "AS IS" with no warranties, and confers no rights. Does implementing an item extender automatically cause the properties to be persisted to the proj file?
I have tried VSHPROPID_ItemSubType, however it will be overwritten with "Designer" in the proj file by VS.NET, if your document uses a visual designer and you change between View Code and View Designer.
The way I have solved it for now:
1. Created a class, HierarchyNode, which is a representation of an IVsHierarchy node. It 'shadows' the VS.Net IVsHierarchy, which I do by enumerating the IVsHierarchy when a new project is loaded. This captures the IVsHierarchy initially.
2. To capture new items added to the hierarchy, I subscribe to the IVsHierarchyEvents::OnItemAdded. When I am notified, I create a new node in my internal hierarchy and set a dirty flag, if the item has properties to be persisted to the project file.
3. HierarchyNode provides virtual methods for GetProperty, ExecCommand and QueryStatusCommand, so one can override the default functionality by subclassing. This allows a much cleaner way to do things like control context menus, change icons, etc, by keeping the code in one place.
4. When VS.NET calls my IPersistXMLFragment::Save method of my IVsProjectFlavorCfg implementation, I call save on my internal hierarchy, and the properties are persisted to the proj file just fine.
Cheers,
Stu
"Gary Chang[MSFT]" - 05 Apr 2006 04:05 GMT That's great, Stuart!
I am glad to know you resolved this issue with your own solution, and thanks for sharing it with us.
For the problem about the item extender, you need to persist the corresponding property in the proj file manually in the extender. Please refer to our related Visual Studio 2005 automation sample --Solution Extender Add-in.
Have a nice day!
Best regards,
Gary Chang Microsoft Community Support ====================================================== PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 AM PST, February 14, 2006. Please complete a re-registration process by entering the secure code mmpng06 when prompted. Once you have entered the secure code mmpng06, you will be able to update your profile and access the partner newsgroups. ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|