Visual studio 在visual studio中或使用命令提示符自动创建搁置集
我想知道是否有办法从VisualStudio中不同工作区的开放解决方案中自动(例如每1小时)创建搁置集(备份) 这是一个扩展,用于在VS Marketplace中自动为所有挂起更改的最新版本创建搁置集Visual studio 在visual studio中或使用命令提示符自动创建搁置集,visual-studio,tfs,shelveset,Visual Studio,Tfs,Shelveset,我想知道是否有办法从VisualStudio中不同工作区的开放解决方案中自动(例如每1小时)创建搁置集(备份) 这是一个扩展,用于在VS Marketplace中自动为所有挂起更改的最新版本创建搁置集 默认情况下,间隔为5分钟,您可以将间隔设置为60分钟以满足您的需要。如果您不想打开VS和特定解决方案的要求,那么我早就编写了这个脚本,它仍然有很多用途 <# .DESCRIPTION This script will create a shelveset for each
默认情况下,间隔为5分钟,您可以将间隔设置为60分钟以满足您的需要。如果您不想打开VS和特定解决方案的要求,那么我早就编写了这个脚本,它仍然有很多用途
<#
.DESCRIPTION
This script will create a shelveset for each workspace it finds in the form "WorkspaceName_dddHHmm"
(ex. 'MyWorkspace_Mon1300' for monday at 1PM/1300). It does NOT require Visual Studio to be running.
.NOTE
The intention is to run this as a Scheduled Task periodically. I run it every hour during my usual working
time, and an hour before and after. With the naming pattern it uses, this means I have a rolling week of
shelvesets that I can refer back to in case of hardware failure, mucking something up, getting work laptop
confiscated by TSA, etc. Its also good for teams to use for sharing code or to check on the progress of
noobs that may not know when to ask for help
#>
$ErrorActionPreference = 'Stop'
$Error.Clear()
Clear-Host
#the collection should be read from somewhere like $HOME\AppData\Roaming\Microsoft\VisualStudio\15.0_f40892c4\Team Explorer\TeamExplorer.config
#but this was easier. This URL is for Azure DevOps, for on premise, use the project collection url you can get from looking at the workitems.
$projectCollectionUrl = "https://yourOrgUrl.visualstudio.com"
try
{
$vsWherePath = Resolve-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$tfExeRoot = & "$vsWherePath" -latest -products * -requires Microsoft.VisualStudio.TeamExplorer -property installationPath
$tfExePath = Join-Path $tfExeRoot "\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe" -Resolve
$workspaces = [xml](& $tfExePath vc workspaces /collection:$projectCollectionUrl /format:xml)
$workspaceFolders = @($workspaces.Workspaces.Workspace.Folders.WorkingFolder.local)
$currentDate = (Get-Date).ToString("ddd_HHmm")
foreach($workspace in $Workspaces.Workspaces.Workspace)
{
$workspaceFolder = $workspace.Folders.WorkingFolder.local | Select-Object -First 1
if (-Not (Test-Path $workspaceFolder))
{
Write-Host "There is no workspace folder at $workspaceFolder" -ForegroundColor Red
continue
}
Set-Location $workspaceFolder
try
{
$shelveSetName = "AutoShelve_$($workspace.Name)_$currentDate"
& "$tfExePath" shelve $shelveSetName /noprompt /replace
}
catch
{
if ($_.Exception.Message -like "*There are no matching pending changes to shelve*")
{
Write-Host "There are no pending changes to shelve for workspace $workspaceFolder" -ForegroundColor Yellow
continue
}
throw
}
}
}
finally
{
Set-Location $PSScriptRoot
}
$ErrorActionPreference='Stop'
$Error.Clear()
清除主机
#应该从$HOME\AppData\Roaming\Microsoft\VisualStudio\15.0\U f40892c4\Team Explorer\TeamExplorer.config等位置读取集合
#但这更容易。此URL适用于Azure DevOps,对于内部部署,请使用您可以通过查看工作项获得的项目集合URL。
$projectCollectionUrl=”https://yourOrgUrl.visualstudio.com"
尝试
{
$vsWherePath=解析路径“${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe”
$tfExeRoot=&“$vsWherePath”-最新-产品*-需要Microsoft.VisualStudio.TeamExplorer-属性安装路径
$tfExePath=加入路径$tfExeRoot“\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe”-解析
$workspaces=[xml](&$tfExePath-vc-workspaces/collection:$projectCollectionUrl/format:xml)
$workspaceFolders=@($workspaces.workspaces.Workspace.Folders.WorkingFolder.local)
$currentDate=(Get Date).ToString(“ddd_HHmm”)
foreach($workspace.workspace.workspace中的workspace)
{
$workspaceFolder=$workspace.Folders.WorkingFolder.local |选择对象-第一个1
if(-Not(测试路径$workspaceFolder))
{
写入主机“在$workspaceFolder处没有工作区文件夹”-ForegroundColor红色
持续
}
设置位置$workspaceFolder
尝试
{
$shelveSetName=“AutoShelve_$($workspace.Name)$currentDate”
&“$tfExePath”搁置$shelveSetName/noprompt/replace
}
抓住
{
if($\ux.Exception.Message-如“*搁置*没有匹配的挂起更改”)
{
写入主机“工作区$workspaceFolder的搁置没有挂起的更改”-ForegroundColor黄色
持续
}
扔
}
}
}
最后
{
设置位置$PSScriptRoot
}