2

context information

I Use the scaffolder nuget package to make database upgrade classes. by calling scaffold dbupgrade in the package manager console.

De upgrade powershell file ends with: Add-ProjectItemViaTemplate ....

What i want

It all works great and generates a class for me and adds it to the project file but: I would like to open the generated file in my solution.

Is this possible? and how would i go from here?

I use visual studio 2015 Community edition.

What I tried

I tried commands such as Open-File, Open-Document but these do not exist.

Community
  • 1
  • 1
Joel Harkes
  • 10,975
  • 3
  • 46
  • 65
  • To comment on this. i did not found a solution yet, although i did not spend a lot of time on this, trying to figure it out. – Joel Harkes Jun 07 '16 at 08:35

1 Answers1

1

I found my solution on another stackoverflow question: https://stackoverflow.com/a/28426592/1275832

the solution would be:

$DTE.ExecuteCommand("File.OpenFile", "App.config")

For a nuget package Install.ps1 you could do:

param($installPath, $toolsPath, $package, $project)

//Get specific file
$file = $project.ProjectItems.Item("`$rootnamespace`$.nuspec")

//Get its location
$location = $proj.ProjectItems.Item("App.config").Properties['LocalPath'].Value

//Open the file in the IDE
$project.DTE.ExecuteCommand("File.OpenFile", $location)
Community
  • 1
  • 1
Joel Harkes
  • 10,975
  • 3
  • 46
  • 65