Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Get current folder where a recipe is executed
 

Get current folder where a recipe is executed

Hello, I am trying to create a class file in an existing project folder.

My main objective is:

- navigate to a specific existing folder in a project
- right mouse click to execute a recipe thatwillgenerate the class in that folder

My main problem is that I don“t know how to retrieve the information about the selected folder (the one i choose with the right mouse click)to pass as argument for an Action.


Can anyone help me?

tks in advance!
jrebelo  Monday, August 18, 2008 2:11 PM

Hi,

You need to make sure you add this to your recipe:

<CommandBar Name="Folder" /> (under the HostData element)


This will ensure your recipe only shows when the currently selected item is a Folder.
Then in your Recipe you will have at least one Action and in it you can use the DTE as in:

dte.SelectedItems.Item(1) to access the Folder object.

and with something like this you can read its fullpath:

SelectedItems.Item(1).ProjectItem.Properties("URL");

If you don't have a DTE instance handy you can retrieve one by asking for the DTE service

DTE dte = GetService(typeof(DTE)) as DTE;

HTH,
-vga.


Working with GAX/GAT/DSL? Download SFT now! http://softwarefactoriestoolkit.net
  • Proposed As Answer byvga Monday, August 18, 2008 7:44 PM
  • Marked As Answer byjrebelo Tuesday, August 19, 2008 10:56 AM
  •  
vga  Monday, August 18, 2008 7:44 PM

Hi,

You need to make sure you add this to your recipe:

<CommandBar Name="Folder" /> (under the HostData element)


This will ensure your recipe only shows when the currently selected item is a Folder.
Then in your Recipe you will have at least one Action and in it you can use the DTE as in:

dte.SelectedItems.Item(1) to access the Folder object.

and with something like this you can read its fullpath:

SelectedItems.Item(1).ProjectItem.Properties("URL");

If you don't have a DTE instance handy you can retrieve one by asking for the DTE service

DTE dte = GetService(typeof(DTE)) as DTE;

HTH,
-vga.


Working with GAX/GAT/DSL? Download SFT now! http://softwarefactoriestoolkit.net
  • Proposed As Answer byvga Monday, August 18, 2008 7:44 PM
  • Marked As Answer byjrebelo Tuesday, August 19, 2008 10:56 AM
  •  
vga  Monday, August 18, 2008 7:44 PM
Hello again!

Tks for the quick anwser.
I used your information to explore the Item structure (using SelectItems). I found other useful info there, and got all that i needed.
Once again, thank you.



jrebelo  Tuesday, August 19, 2008 10:56 AM

You can use google to search for other answers

Custom Search

More Threads

• Install Error for Guidance Automation Extensions - February 2008 Release
• How do you include a folder that has been excluded from a project?
• Guidance Package Manager not visible in VS2008SP1 - captured a dump with the troubleshooting utility - please advise
• GAX VS 2005 - "Cannot find registration information for template "...". Package templates may not be properly registered. Run package installation again and verify template name and location.
• Toolkit Error: The following arguments are required and don't have values
• Create Typed Dataset with EnvDTE
• XML Literal in .tt template
• Change location solution is unfolded to
• Installing Clarius SFT for July 2007 GAT CTP
• Unable to see my custom developed Guidance Automation Package under VisualStudio template