powershell - 如何用 Powershell 替换 Visual Studio 命令提示符?

标签 powershell

我正在尝试以下命令的各种变体:

powershell -command "'C:\Program Files (x86)\Microsoft Visual Studio 10.0\vc\vcvarsall.bat' x86" -noexit

我希望使用 VS 环境变量运行 Powershell - 但无济于事。我只是无法正确引用。

最佳答案

看看 PowerShell Community Extensions .它带有一个调用批处理文件的命令,“记住”它设置的环境变量并将它们带入您的 PowerShell session 。事实上,我的个人资料就是用 VS 变量来实现的,例如:

Import-Module Pscx

function Import-VS9Vars
{
    $vcargs = ?: {$Pscx:Is64BitProcess} {'amd64'} {'x86'}
    Push-EnvironmentBlock -Description "Before importing VS 2008 $vcargs var"
    Invoke-BatchFile "${env:VS90COMNTOOLS}..\..\VC\vcvarsall.bat" $vcargs
}

function Import-VS10Vars
{
    $vcargs = ?: {$Pscx:Is64BitProcess} {'amd64'} {'x86'}
    Push-EnvironmentBlock -Description "Before importing VS 2010 $vcargs vars"
    Invoke-BatchFile "${env:VS100COMNTOOLS}..\..\VC\vcvarsall.bat" $vcargs
}

Import-VS10Vars

重要的命令是 Invoke-BatchFile。此函数的源代码包含在下载中,因此如果您不想使用整个模块,您可以根据需要只复制一个函数。

关于powershell - 如何用 Powershell 替换 Visual Studio 命令提示符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7298764/

相关文章:

powershell - 运行pester测试时如何使管道中的输出出现在控制台上?

powershell - 检查 Windows 服务是否存在并在 PowerShell 中删除

Azure Pipelines 代理代理设置未按预期工作

html - 如何使用 Powershell Core 7 解析 HTML 表格?

linux - "New-AzureStorageContext"无法识别。 Linux

powershell - 远程使用 Get-ODBCDSN

powershell - Import-DscResource 找不到包 cChoco

powershell - 使用 Powershell 从 CNAME 记录中解析 IP 地址

powershell - 如何在Powershell中测试无效路径?

powershell - 访问被拒绝将域用户添加到本地管理员组