简体   繁体   English

在Visual Studio PowerShell窗口中包括自定义cmdlet

[英]Include custom cmdlets in Visual Studio PowerShell window

My company is using Visual Studio 2015 which has the very practical PowerShell Interactive Window and also the NuGet Paket Manager Console, which is basically a PowerShell host. 我的公司正在使用Visual Studio 2015,它具有非常实用的PowerShell交互式窗口以及NuGet Paket Manager控制台,该控制台基本上是PowerShell主机。

We would like use some of our own cmdlets in one of these windows. 我们想在其中一个窗口中使用一些自己的cmdlet。 Is there any way I can configure to load them 'automatically', similar to the auto-loaded user profile in PowerShell? 有什么方法可以配置为“自动”加载它们,类似于PowerShell中的自动加载用户配置文件吗? Preferably based on the currently opened solution, if possible. 如果可能,最好基于当前打开的解决方案。

Please consider: Using the regular PowerShell profile will not work, because it is not loaded in these windows. 请考虑:使用常规PowerShell配置文件将不起作用,因为这些窗口中未加载该配置文件。 Also, even if it did work, this would be a solution on a per user basis only. 同样,即使它确实起作用,也只能是基于每个用户的解决方案。

(Note: These cmdlets are script cmdlets, but I think/hope this won't make a big difference.) (注意:这些cmdlet是脚本cmdlet,但是我认为/希望这不会有太大的不同。)

Start your powershell interactive / Nuget package manager window and type $profile . 启动您的powershell交互式/ Nuget软件包管理器窗口,然后输入$profile You'll see where your profile is defined. 您会看到个人资料的定义位置。 You can then add your own cmdlets to that profile. 然后,您可以将自己的cmdlet添加到该配置文件。 See this article for more information. 有关更多信息,请参见本文

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

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