Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > ValueProvider for the first selected Item in a project?
 

ValueProvider for the first selected Item in a project?

I am trying to derive a string from the currently selected item in a project.

e.g. - I have a file called "MyData.xsd" selected in the project. I would like to be able to get a handle on that item from a ValueProvider so I can get the name of it.

I see the CurrentSelectedProject ValueProvider but have not been able to find anything for CurrentSelectedItem. my first instinct was to inspect the Properties collection on the Project, but I didn't see anything useful for this situation there.

Is there already aValueProvider that will get me that Item? If not, are there any suggestions/hints as to how I might access it within my own ValueProvider?

chooch  Friday, March 10, 2006 4:36 PM

figured it out.

it's as simple as using an Evaluator and having these 2 arguments like this:

<Argument Name="CurrentProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

<ValueProvider Type="Microsoft.Practices.RecipeFramework.Library.ValueProviders.FirstSelectedProject, Microsoft.Practices.RecipeFramework.Library" />

</Argument>

<Argument Name="ItemName">

<ValueProvider Type="Evaluator" Expression="$(CurrentProject.DTE.SelectedItems.Item(1).Name)" />

</Argument>

chooch  Friday, March 10, 2006 8:49 PM

figured it out.

it's as simple as using an Evaluator and having these 2 arguments like this:

<Argument Name="CurrentProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

<ValueProvider Type="Microsoft.Practices.RecipeFramework.Library.ValueProviders.FirstSelectedProject, Microsoft.Practices.RecipeFramework.Library" />

</Argument>

<Argument Name="ItemName">

<ValueProvider Type="Evaluator" Expression="$(CurrentProject.DTE.SelectedItems.Item(1).Name)" />

</Argument>

chooch  Friday, March 10, 2006 8:49 PM
Hi there,

I have a question related with this topic.
Is it possible to pass to the action the ProjectItem itself and not only it´s name?...
One workaroud would be to pass to the action the selected Project and then select the first selected item... But it is a much cleanner solution just to pass the current selected project item...

Help?...

Thank you.

JCR
jrebelo  Thursday, July 16, 2009 5:43 PM
Found the anwser:


<Arguments>

<Argument Name="CurrentProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<ValueProvider Type="Microsoft.Practices.RecipeFramework.Library.ValueProviders.FirstSelectedProject, Microsoft.Practices.RecipeFramework.Library" />
</Argument>

<Argument Name="ProjectSvcItem" Type="EnvDTE.ProjectItem, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<ValueProvider Type="Evaluator" Expression="$(CurrentProject.DTE.SelectedItems.Item(1).ProjectItem)" />
</Argument>

</Arguments>
jrebelo  Friday, July 17, 2009 1:28 PM

You can use google to search for other answers

Custom Search

More Threads

• Trying To Use Solution Folders for Projects
• How to create a database project with template?
• Nested Solution Folder Parent?
• Get a project reference to a website project
• Changing the folder of custom tool generated files
• Problem with Package Building (2 projects included as .vstemplate, but references not being resolved)
• GAT/GAX for VS2005 RTM released!
• Argument Expansion - Unfold Template
• Problem with Specifying Command Bars
• DTE Set Startup Project?