Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a link to a file in visual studio using EnvDTE

I am writing a custom scaffolder for our project. And this scaffolder should add links to DTO declarations for client side app.

I have a possibility to retrieve an instance of project item,

$folder = Get-ProjectFolder "Views\Shared" 

and I already found that it is possible to add links using ProjectNode.AddNewFileNodeToHierarchy(string, string) method.

I can get a reference to the DTE service by simply accessing $DTE variable predefined in PowerConsole.

The question is how to get instance of ProjectNode I am interested in?

like image 348
v00d00 Avatar asked Mar 05 '12 11:03

v00d00


1 Answers

Ok, it was easier than I thought.

Here is a snippet I finished with:

$targetFolder = Get-ProjectFolder "Services" -Project "ServiceModel.Silverlight"
$sourceFile = Get-ProjectItem $ServiceInterfaceOutputPath -Project "ServiceModel"
$sourceFile.Open()
$targetFolder.AddFromFile($($sourceFile.Document.FullName))

In case you are not working with t4 scaffolder, this link can be helpfull : http://social.msdn.microsoft.com/Forums/en/vsx/thread/168d23c8-eee8-4486-a412-147b67673593

like image 112
v00d00 Avatar answered Sep 18 '22 19:09

v00d00