代码之家  ›  专栏  ›  技术社区  ›  roundcrisis

visual Studio 2010中加载设置文件的宏

  •  5
  • roundcrisis  · 技术社区  · 15 年前

    我只是在寻找一种方法(也许是宏?)加载设置文件。 理想情况下,我想能够运行这个作为一个快捷方式从桌面上也。

    2 回复  |  直到 15 年前
        1
  •  5
  •   roundcrisis    15 年前

    这是一个适用于我的宏。

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

    一些文件 here

        2
  •  0
  •   Casper Leon Nielsen    9 年前

    在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()
    }