I have been using TFS from the same laptop for 5 years. The laptop is being replaced and I am setting up the new one.
On the old laptop I could access TFS via VS2010 to “manually” check sources in and out. However I found it quicker to do this with a batch file that called tf.exe to check the source in/out.
On the new laptop I can access TFS via VS2017 to “manually” check sources in and out. I modified the batch file to include the new path for tf.exe but when I execute it, I get an error “The item… cannot be found in your workspace, or you do not have permission to access it”. The file(s) I try and check out are definitely where they should be and, as far as I am aware, I have full access to the folder.
Can anyone offer suggestions as to how I might resolve this? Thanks in advance.
I have tried executing the batch file from the local workspace folder and have verified using "tf vc workspaces" that the local folder is where I think it is.
Might it be something to do with using accessing TFS from both laptops using same credentials I wonder?
I finally resolved this in VS2017 by unbinding the local workspace (File/Source Control/Advanced/Workspaces/Remove) then recreating it (File/Source Control/Advanced/Workspaces/Add) then the tf command started to work.
I also cleared the cache (removed all files and folders within it) contained in users\myname\appdata\local\Microsoft\Team Foundation\7.0\Cache (Windows 10) because that was suggested by some threads arising from other Google searches but I don't think it necessarily helped.
I am currently upgrading our XAML build definitions to the new build system. Already squashed a few errors, but now I am at a point where I can no longer tell what could be wrong. We use PowerShell scripts for most of the build process, and although all required data is available on the server, I get the following error when running the build:
Does anyone have any idea what could cause that error? Or at least where I should check?
Thanks in advance.
EDIT:
The script prepares build configuration that can not be done by external tools and are specific to our project. The error happens on the line $teamProjectCollection =...
Function Get-BuildNumberFromUri() {
<#
.SYNOPSIS
Reads the build number from the current TFS build ($Env:BUILD_BUILDURI)
.DESCRIPTION
Reads the build number from the current TFS build ($Env:BUILD_BUILDURI)
.NOTES
May fail if $env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI or $env:BUILD_BUILDURI
are not set
#>
[String] $CollectionUrl = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"
[String] $BuildUrl = "$env:BUILD_BUILDURI"
if (-not $CollectionUrl -or -not $BuildUrl) {
return "0"
}
[void[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.Build.Client")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.TeamFoundation.VersionControl.Client")
$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($CollectionUrl)
$buildServer = $teamProjectCollection.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
$buildDetail = $buildServer.GetBuild($BuildUrl)
$buildNumber = $buildDetail.BuildNumber
return $buildNumber
}
Here's the problem:
You're using a new build system. You need to step back and re-evaluate the existing scripts you have in context of the capabilities of the new build system.
You have this big PowerShell snippet that retrieves the build number. That's awesome, except for two things:
It's never going to work -- the SOAP object model does not have any awareness of "new" (e.g. non-XAML) builds. There is a REST API for them, instead.
You can retrieve the current build number by looking at the $env:BUILD_BUILDNUMBER variable. No special code necessary.
In previous versions of Team Foundation Server the Client Object Model was registered in the GAC and pre-loaded by the build agent when running XAML. In the new agent the build steps are independent of the client object model.
You have two options to locate the Client Object Model assemblies:
Ship the Client object model with the powershell scripts by referencing the Client Object Model Nuget package.
https://www.nuget.org/packages/Microsoft.TeamFoundationServer.Client
https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient
Detect the location where Visual Studio is installed and loading the client object model from the Team Explorer extension folder. Examples can be found on the docs wiki.
There is also an easier, but officially unsupported option:
Do not use $(Agent.ServerOMDirectory). It is not safe for task authors to depend on the SDK bundled with the agent. Agent.ServerOMDirectory is a convenience variable that points to the latest SDK bundled with the agent. The SDK may have breaking interface changes between different versions. Depending on the latest version shipped with the agent will cause your task to be unreliable.
Getting at the buildnumber
There is a build variable being populated to set the build number in your script it can be referenced using $env:Build.BuildNumber.
To set the build number write a special statement to the console using
$value = "$($env:Build.BuildNumber)_US`
Write-Host "##vso[build.updatebuildnumber]$Value"
Alternatively you can use my Set Variable task from the VSTS Variable Toolbox extension.
When I try to get latest version of project in TFS it does not work and produces this error:
'Source Control Explorer. Unable to read data from transport connection. The connection was closed.' How do I fix this so I can get the latest version of the project's code?
According the error message seems like the connection to the server was made but since the service was not available on machine, then the sever canceled the request.
You could try below ways to narrow down the issue:
First check the event view on the TFS server if there are some
related error info.
Try to get another team project in some collection and different team
project collection.
Try to use another account to get latest on your machine.
Try to use your account to get latest on another machine. If the
issue only occurs on your machine, you may need to clear TFS and VS
cache which may do the trick.
If you are using Window Server 2008R2. Maybe it's related this
issue. Applied the HotFix and try the workaround.
I am using TFS2015 and VS2010 ultimate.
I map a solution from solution explorer to my local folder. Now when I restart my system. I need to map that project to my local folder again. Why is this happening. And when I tried to map again then got the error that project already mapped.
1). Use the following code to check whether workspace is created successfully:
TfsTeamProjectCollection tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("tfsURL"));
VersionControlServer vcs = (VersionControlServer)tpc.GetService(typeof(VersionControlServer));
Workspace ws = vcs.GetWorkspace("$/teamproject");
string workspacename = ws.Name;
2). If the workspace is created successfully, however, you still get the "project already mapped" message, then please firstly clean the local TFS cache and then re-connect again. To clean TFS cache, delete the "%localappdata%\Microsoft\Team Foundation\6.0\Cache\" folder.
I have referred to a lot of forums and also this so question but my problem is that I have formatted my machine. So I'm not able to overcome this issue. I have tried deleting workspaces from visual studio command prompt and also clearing cache, but I feel this mapping is more on the server-side than local cache, because my machine was formatted. I don't know which file has this old working path saved.
Also I have tried downloading the project into a new working path. I was able to download, but then I don't get the TFS icon against each file. i.e.it's like working offline (disjoint from TFS database). On right click we generally have an option to return online or go online. In this case on right click I get TEAM -> Apply Patch & TEAM -> Share Project
Please help me with this.I had the same problem in my asp.net projects, when I simply downloaded them onto a new working path it worked fine. But this java project in eclipse just doesn't seem to connect to tfs when downloaded into a new path nor does it allow to download in the old path.
Please not I have formatted the machine.So my case is different, so this may not be a possible duplicate of other SO questions.
I did not disconnect or delete workspace before a format(due to lack of knowledge) at that point. May be doing that would never cause this.
All I did is check in all files and re-formatted my windows.
I'd suggest using the (free) tool TFS Sidekicks: http://www.attrice.info/cm/tfs/
This will give you a GUI to view all workspaces (across all users and machines), and delete the obsolete ones.
This is stored on the server, but the tf workspace command should be able to remove it for you. You will probably need to supply it with the correct machine name to find it:
tf workspaces /computer:* /owner:domain\jesse.houwing /collection:http://yourserver:8080/tfs/DefaultCollection
Find the missing workspace (the one that was formatted) and remove it from the server:
tf workspace /delete /collection:http://yourserver:8080/tfs/DefaultCollection workspaceName;domain\jesse.houwing
Do not confuse tf workspaces /remove and tf workspace /delete, the former only removes the registration from your machine, the second removes it from the server.
Or, if the computer name and the username have stayed the same, edit the workspace and delete the paths no longer valid (or update them to their new location) by changing the workspace configuration. Use
tf workspace workspaceName;Owner
to open the dialog to edit your current workspace.
Or use
tf workspaces /updateComputerName /updateUserName
To reassign the workspace from the old computer (iinstallation) or user to the new one.
I tried using the TFS sidekick tool, but even then, ran into access denied error. Then I had to manually clear off the files from this path:
C:\ProgramData\Microsoft Team Foundation Local Workspaces
So this can be alternative, if you do not want to install a tool or your company does not allow you to install software from unknown sources on your laptops due to policies.
This already has a marked answer but my problem was solved without command line or additional software.
I had just recently updated to '15 and I was migrating my workspace folder to another drive as it was getting too big. The error being uninformative as it was, still appeared even after I deleted the workspace it cited...or so i thought. Both VS'13 and '15 by default made the same named workspace but one for each version. I had to reopen '13, and delete that workspace then move back to '15 where it would now let me remap my folder.
Hope this helps someone.
logout from previous user and login by new user.
Copy Project Folder to Another path.
In team Explorer Right click on project and Remove mapping.
Remap Project
go to Control Panel --> User Accounts --> Manage your credentials --> Edit tfs User Name
user name : your TFS user.
I solved it like this.
I had the same problem.
TFS workspace manager throw me this error:
"The working folder \PATH\ is already in use by the workspace my_computer_name name_of_previous_user on computer my_computer_name"
I solved this problem by creating user in TFS server and deleting the previous one.
U can go to TEAM> TEAM PROJECT SETTINGS > SECURITY.
& if u have permission- create your own user.
This is what I did to get it to work using Manage Workspaces in VS:
Click on Show remote workspaces, delete remote workspaces as I was not using them anyway, not sure if this was needed.
Created a new Workspace B and mapped to another folder Y and choose yes to download all files now.
Deleted original workspace A, mapped to Folder X.
Recreate original workspace A and remap to folder Y (wrong folder) and choose Yes to download all files now.
Delete Workspace B
Edit Workspace A, go to Advanced. At the bottom where it says Wroking Folders, change the Local Folder path back to folder X and choose yes to download all files now.
Not sure if you have to do all those steps but that is what I did to finally get this remapped, only took all day.