简体   繁体   English

通过 nuget 管理器控制台在 Visual Studio 中打开文件

[英]Open file in visual studio via nuget manager console

context information上下文信息

I Use the scaffolder nuget package to make database upgrade classes.我使用scaffolder nuget 包来制作数据库升级类。 by calling scaffold dbupgrade in the package manager console.通过在包管理器控制台中调用scaffold dbupgrade

De upgrade powershell file ends with: Add-ProjectItemViaTemplate ....德升级powershell文件以: 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.我使用 Visual Studio 2015 社区版。

What I tried我试过的

I tried commands such as Open-File , Open-Document but these do not exist.我尝试过诸如Open-FileOpen-Document命令,但这些都不存在。

I found my solution on another stackoverflow question: https://stackoverflow.com/a/28426592/1275832我在另一个 stackoverflow 问题上找到了我的解决方案: 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:对于 nuget 包Install.ps1您可以执行以下操作:

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM