【发布时间】:2022-08-07 14:17:10
【问题描述】:
我在 Visual Studio 中做了很多 Winforms 和 WPF GUI 设计,然后在 Visual Studio Code 中进一步完善我的表单。 (我正在使用 Ironman Studios 的 PowerShell Pro Tools)
在 VSCode 中,为 PowerShell 添加和使用 sn-ps 非常容易,尤其是安装了 Snippet Generator 和 Snippets Viewer 插件后:
我试图在 Visual Studio Community 2022 中以某种方式复制它。我已经使用以下代码定义了一个 PowerShell sn-p:
<?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\\Username\\Documents\\Visual Studio 2022\\Code Snippets\\PowerShell\\My Code Snippets\\EnableVisualStyles.snippet
然后,打开一个 PowerShell 文件,我右键单击并选择 Snippet > Insert Snippet:
但我得到一个空的输入框,这里显示:
无论我在该框中输入什么,例如 sn-p 的快捷方式名称,我都没有收到任何建议,如果我按 Enter 键,我会收到以下错误:
我错过了什么吗?有什么方法可以访问 PowerShell sn-ps in.ps1 文件?
市场上是否有某种扩展可以增加对 sn-ps 的扩展支持?
这对我来说非常重要,因为我在开发时非常依赖我的 sn-ps 库。
任何帮助都将受到极大的欢迎。
标签: visual-studio code-snippets visual-studio-extensions visual-studio-2022