Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 版本,但查看不同的VS安装。基本上,我希望它能从一个命令更新所有这些命令。我想我有一个解决方案,但我会更新问题以反映实际问题。 tf proxy /configure @echo off set TFDIR=%vs120comnTools%..\IDE _Visual Studio_Batch File_Tfs_Proxy - Fatal编程技术网

Visual studio 版本,但查看不同的VS安装。基本上,我希望它能从一个命令更新所有这些命令。我想我有一个解决方案,但我会更新问题以反映实际问题。 tf proxy /configure @echo off set TFDIR=%vs120comnTools%..\IDE

Visual studio 版本,但查看不同的VS安装。基本上,我希望它能从一个命令更新所有这些命令。我想我有一个解决方案,但我会更新问题以反映实际问题。 tf proxy /configure @echo off set TFDIR=%vs120comnTools%..\IDE ,visual-studio,batch-file,tfs,proxy,Visual Studio,Batch File,Tfs,Proxy,版本,但查看不同的VS安装。基本上,我希望它能从一个命令更新所有这些命令。我想我有一个解决方案,但我会更新问题以反映实际问题。 tf proxy /configure @echo off set TFDIR=%vs120comnTools%..\IDE set Path=%Path%;%TFDIR% tf proxy /enabled:false echo[ echo Configuring Proxy tf proxy /configure /collection:[MyUrl] PAU

版本,但查看不同的VS安装。基本上,我希望它能从一个命令更新所有这些命令。我想我有一个解决方案,但我会更新问题以反映实际问题。
tf proxy /configure
@echo off
set TFDIR=%vs120comnTools%..\IDE
set Path=%Path%;%TFDIR%

tf proxy /enabled:false

echo[
echo Configuring Proxy
tf proxy /configure /collection:[MyUrl]
PAUSE
#TODO: Replace [MyUrl] With the collection Url

#Add New Versions to this list when new versions of VS are released
$VsVersionsToDisable = "10.0", "11.0", "12.0", "14.0"

[System.Collections.ArrayList]$VsVersions = $VsVersionsToDisable
[String]$VsProxyVersionToUse = ""

#Find the Highest installed VS Version, and use it for the TFS.exe Command.
foreach ($version in $VsVersions | Sort-Object -Descending)
{
    $keyPath = "HKCU:\Software\Microsoft\VisualStudio\$version`_Config"
    If (Test-Path $keyPath)
    {
        $aliasPath = Get-ItemProperty -Path $keyPath | Select-Object `
                               -ExpandProperty InstallDir
        $proxyPath = Join-Path $aliasPath "tf.exe"
        set-alias proxyTF $proxyPath

        #Remove the VS Version we're using from the array 
        #the command will auto-set this value, so we don't need to manually set it.
        $VsVersions.Remove($version)
        $VsProxyVersionToUse = $version

        break
    }
}

#Gets the last Check time from the Auto-Configuration, to update the other
#versions
function Get-ProxyLastCheckTime()
{
    return Get-ItemProperty `
    "HKCU:\Software\Microsoft\VisualStudio\$VsProxyVersionToUse\TeamFoundation\SourceControl\Proxy" `
    | Select-Object -ExpandProperty LastCheckTime
}

#For each installed version, updates the proxy settings.
function Set-VSIDEConfig
(
    [String]
    [Parameter(Mandatory=$true)]
    $proxyUrl
)
{
    $lastCheckTime = Get-ProxyLastCheckTime

    foreach ($version in $VsVersions)
    {
        Push-Location

        $regPath = "HKCU:\Software\Microsoft\VisualStudio\$version\TeamFoundation\SourceControl\Proxy"

        if (Test-Path $regPath)
        {
            Write-Output "Updating Proxy IDE Settings for VS $version"
            Set-Location $regPath

            Set-ItemProperty . Enabled $true
            Set-ItemProperty . Url $proxyUrl
            Set-ItemProperty . AutoConfigured $true
            Set-ItemProperty . LastCheckTime $lastCheckTime
            Set-ItemProperty . LastConfigureTime $lastCheckTime
        }

        Pop-Location
    }
}

#Disables the Current proxy Settings.
function Disable-VSIDEConfig()
{
    foreach ($version in $VsVersionsToDisable)
    {
        Push-Location

        $regPath = "HKCU:\Software\Microsoft\VisualStudio\$version\TeamFoundation\SourceControl\Proxy"

        if (Test-Path $regPath)
        {
            Write-Output "Disabling Proxy IDE Settings for VS $version"
            Set-Location $regPath

            Set-ItemProperty . Enabled $false
        }

        Pop-Location        
    }
    Write-Output ""
}

#Process the response from the Proxy command.
function Process-ProxyResult
(
    [String[]]
    [Parameter(Mandatory=$true)]
    $result
)
{
    $resultUrl = $result | Select -Last 1

    if ($resultUrl -match "Successfully configured proxy (?<content>.*)\.") 
    {
        $url = $matches["content"].Trim()

        #Update the IDE Settings with the new proxy
        Set-VSIDEConfig $url
    }   
    Write-Output ""
}

#Run the TFS Proxy Setup.
function Set-TFSProxy()
{
    #First, Disable the proxy settings
    proxyTF proxy /enabled:$false
    Disable-VSIDEConfig

    Write-Output "Getting Proxy data from Team02"
    #TODO: Replace [MyUrl] With the collection Url
    $output = proxyTF proxy /configure /collection:[MyUrl] 2>&1
    Write-Output $output

    Write-Output ""
    Process-ProxyResult $output
}

    #Run it by default.
Set-TFSProxy