有没有办法在Visual Studio 2022中创建和使用PowerShell片段?
我在Visual Studio中做了很多Winforms和WPF GUI设计,然后在Visual Studio代码中进一步完善了我的形式。 (我正在使用Ironman Studios的PowerShell Pro Tools)
在VSCODE中,添加和使用摘要非常容易用于PowerShell,尤其是使用 smippet Generator
和
simpets viever
安装了添加剂> :
我正在尝试以某种方式在Visual Studio Community 2022中复制此此内容。我已经定义了具有以下代码的PowerShell片段:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>GUI Enable Visual Styles</Title>
<Description>Enable Visual Styles</Description>
<Shortcut>enablevs</Shortcut>
</Header>
<Snippet>
<Code Language="PowerShell">
<![CDATA[
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName PresentationCore,PresentationFramework
[System.Windows.Forms.Application]::EnableVisualStyles()
]]>
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
并且我在此处保存了该文件: c:\ users \ user \ username \ Documents \ Visual Studio 2022 \ Code Sippets \ PowerShell \ My Code Sippets \ EnableVisualStyles.snippet
然后,使用PowerShell文件打开,我右键单击并选择 snippet&gt;插入snippet
:
但我在此处显示一个空输入框:
无论我在该框中输入什么,例如摘要的快捷方式名称,我都没有得到建议,如果我按ENTER,我会收到以下错误:
有什么方法可以在.ps1文件中访问powershell片段?
市场上是否有某种扩展可以增加对摘要的扩展支持?
这对我来说至关重要,因为我在开发时很大程度上依赖摘要库。
任何帮助都将受到极大的欢迎。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到了Visual Studio 2022 Community Edition的问题。根据我在VS2022的经验,它剩下太多了。
您可以尝试从Visual Studio Marketplace下载和安装“ Visual Studio 2022的PowerShell工具”(假设您还没有这样做)。
Visual Studio的PowerShell工具2022:
https://marketplace.visualstudio.com/items?itemName=AdamRDriscoll.PowerShellToolsVS2022
即使安装了PowerShell工具,我仍然遇到问题,因为Microsoft似乎已经烧毁了大多数PowerShell资产,尤其是与WPF等有关。
就个人而言,我厌倦了玩“ Visual Studio 2022”,最终我卸载了,而是在其上安装了“ Visual Studio 2019”。
Visual Studio 2019下载:
https://learln.microsoft.com/en-en-us/en-en-us/ VisualStudio/releases/2019/Release-Notes
与VS2022一样,“ Visual Studio的PowerShell工具”扩展名与VS2017兼容,需要安装VS2017和VS2019。
Visual Studio的PowerShell工具(VS2017&amp; VS2019):
VS2019版本之间的主要区别在于,PowerShell资产和资源(包括WPF,表单,脚本,模块等)仍然可用。
我确实对PowerShell片段进行了一些研究,似乎它们仅针对“ Visual Studio Code”。
PowerShell(Visual Studio Code):
https://marketplace.visualstudio.com/itemnemnemnemnemnememnememnemame=ms-vscode.itemnementplace.visalstudio.com/itemnementemnememtemnemename=mvscode。 PowerShell
如果您有能力购买商业扩展,您还可以为Visual Studio寻找“ PowerShell Pro Tools”。
PowerShell Pro工具:
https://ironmansoftware.com/powershell-pro-tools 。希望此信息对您有所帮助。
如果我遇到任何其他信息,这可能对您有利,我一定会发布更新。
I too ran into this problem with Visual Studio 2022 Community Edition. Based on my experience with VS2022, it leaves too much to be desired.
You could try Downloading and Installing "PowerShell Tools for Visual Studio 2022" from the Visual Studio Marketplace (assuming you haven't done so already).
PowerShell Tools for Visual Studio 2022:
https://marketplace.visualstudio.com/items?itemName=AdamRDriscoll.PowerShellToolsVS2022
Even after installing the PowerShell Tools, I kept running into problems, as it seems Microsoft has gutted the majority of the PowerShell Assets, especially in relation to WPF and the like.
Personally, I got tired of playing around with "Visual Studio 2022", which I ultimately Uninstalled and instead, Installed "Visual Studio 2019" in it's place.
Visual Studio 2019 Downloads:
https://learn.microsoft.com/en-us/visualstudio/releases/2019/release-notes
Much like VS2022, the "PowerShell Tools for Visual Studio" extension, that is compatible with VS2017 and VS2019 needs to be Installed.
PowerShell Tools for Visual Studio (VS2017 & VS2019):
https://marketplace.visualstudio.com/items?itemName=AdamRDriscoll.PowerShellToolsforVisualStudio2017-18561
The major difference, between the VS2019 Version, is that the PowerShell Assets and Resources (including WPF, Forms, Scripting, Module, etc.) are still available.
I did do some research into the PowerShell Snippets and it seems that they are specific to "Visual Studio Code" only.
PowerShell (Visual Studio Code):
https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell
You could also look into "PowerShell Pro Tools" for Visual Studio, if you can afford to purchase a commercial extension.
PowerShell Pro Tools:
https://ironmansoftware.com/powershell-pro-tools
That is all I have for now. I hope this info helps you out.
If I run into any other Information, that may be beneficial to you, I'll be sure to post an Update.