Visual Studio Code $psise 等价物 [英] Visual Studio Code $psise equivalent

查看:69
本文介绍了Visual Studio Code $psise 等价物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在 VSCode 中复制 $psISE 功能的方法,至少就在编辑器中发现打开的活动文件的文件名而言.

I'm looking for a way to replicate the $psISE functionality in VSCode, at least as far as discovering the filename of the open, active file in the editor.

作为背景:

我正在尝试迁移到使用 VSCode 进行 Powershell 编辑而不是 ISE,因为 VSCode 是未来.我们在迁移某些工作流(特别是签名脚本)时遇到了问题.在 ISE 中,我创建了一个使用 $psise.currentfile.fullpath 的函数,以便我们可以轻松地对在 ISE 中打开的文件进行签名.我想为 vscode 重新创建这个,但我没有找到任何方法来确定打开的文件是什么.我们倾向于以交互方式运行它(即,我们在 ISE 中进行测试,将它带到我们想要在另一个盒子上进行测试的位置,然后只需键入 Set-CoSAuthenticodeSignature 对其进行签名,这是一个自定义函数包装 set-authenticodesignature 但设置了默认值并自动查找文件,如果我们不指定),所以我们不想一直输入路径名,特别是因为我们现在不必了.

I'm trying to migrate into using VSCode for powershell editing instead of the ISE since VSCode is the future. We're having issues with migrating some workflows (specifically signing scripts). In the ISE, I have created a function that uses the $psise.currentfile.fullpath so that we can easily sign the file that's open in the ISE. I'd like to recreate this for vscode, but I'm not finding any way to determine what the open file is. We tend to run this interactively (i.e. we're testing in the ISE, get it to where we want to test on another box, and sign it by just typing Set-CoSAuthenticodeSignature, which is a custom function that wraps set-authenticodesignature but has defaults set and automatically finds the file, if we don't specify), so we don't want to have to type the path name all the time, especially since we don't have to now.

谢谢!

推荐答案

我认为它还没有实现($psise).您可以在 VSCode 的 vscode-powershell 项目上提交问题.类似的已经提交.

I think it's not implemented yet (the $psise). You can file an issue on the vscode-powershell Project for VSCode. A similar one has already been filed.

至少你可能会使用类似的东西$context = [Microsoft.Powershell.EditorServices.Extensions.EditorContext]$psEditor.GetEditorContext()

At least you might use something like $context = [Microsoft.Powershell.EditorServices.Extensions.EditorContext]$psEditor.GetEditorContext()

然后就可以访问当前文件了...$context.CurrentFile.

Then you can access the current file... $context.CurrentFile.

另请参阅此视频了解简介...

See also this video for an introduction...

这篇关于Visual Studio Code $psise 等价物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆