开发者

Macro in visual Studio 2010 that loads settings file

I'm just looking for a way (maybe a macro?) 开发者_如何学Goto load a settings file. Ideally I'd like to be able to run this as a shortcut from the desktop too. I googled it, but maybe I didn't hit the right keywords.


This is a macro that works for me.

Sub MySub()
    DTE.ExecuteCommand("Tools.ImportandExportSettings", "/import:""<full path to settings file>""")
End Sub

Some Docs here


In PowerShell:

function Import-VisualStudioSettingsFile {
    [CmdletBinding()]
    param(
        [string] $FullPathToSettingsFile,
        [string] $DevEnvExe = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe",
        [int] $SecondsToSleep = 20 # should be enough for most machines
    )

    if(-not (Test-Path $DevEnvExe)) {
        throw "Could not find visual studio at: $DevEnvExe - is it installed?"
    }

    if(-not (Test-Path $FullPathToSettingsFile)) {
        throw "Could not find settings file at: $FullPathToSettingsFile"
    }

    $SettingsStagingFile = "C:\Windows\temp\Settings.vssettings" # must be in a folder without spaces
    Copy-Item $FullPathToSettingsFile $SettingsStagingFile -Force -Confirm:$false

    $Args = "/Command `"Tools.ImportandExportSettings /import:$SettingsStagingFile`""
    Write-Verbose "$Args"
    Write-Host "Setting Tds Options, will take $SecondsToSleep seconds"
    $Process = Start-Process -FilePath $DevEnvExe -ArgumentList $Args -Passthru
    Sleep -Seconds $SecondsToSleep #hack: couldnt find a way to exit when done
    $Process.Kill()
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜