TFS on premise requires you to keep your TFS updated as almost in every quarter a new update to the TFS is released as well as a new version every year. For this you might have to do TFS Upgrades. If you have upgraded from TFS 2015 to TFS 2018 you have to remove the version 1.xx build agents and configure version 2.xx build agents. Your existing build might encounter workspace issues and may not be able to get sources downloaded to build, in the build agents after the upgrade of agents done. Let’s look at how we can get this issue resolved.
Build is unable to Get source from TFVC and failing giving workspace has already mapped to bla bla… issues. Sample error message below.
2017-12-29T09:14:36.4444548Z ##[section]Starting: Get Sources
2017-12-29T09:14:36.6007172Z Prepending Path environment variable with directory containing 'tf.exe'.
2017-12-29T09:14:36.6007172Z Setting environment variable TFVC_BUILDAGENT_POLICYPATH
2017-12-29T09:14:36.6163431Z Querying workspace information.
2017-12-29T09:14:41.4738215Z ##[command]tf vc workspace /new /location:local /permission:Public ws_8_103 /collection:http://tfs:8080/tfs/collectionY/ /loginType:OAuth /login:.,******** /noprompt
2017-12-29T09:14:43.0039068Z The path e:\b\2\8\s\someproj\DevOps is already mapped in workspace ws_8_6;Build\1b82d782-2173-4f30-99e5-0c4ecac9960a [http://tfs.com:8080/tfs/collectionX].
2017-12-29T09:14:43.1444995Z ##[error]Exit code 100 returned from process: file name 'tf', arguments 'vc workspace /new /location:local /permission:Public ws_8_103 /collection:http://tfs.com:8080/tfs/collectionY/ /loginType:OAuth /login:.,******** /noprompt'.
2017-12-29T09:14:43.1601263Z ##[section]Finishing: Get Sources
The real issue is a some folder from a different collection(collectionX) mapped to the workspace the code is trying to download for another collection (CollectionY).
The permanent fix for this issue is removing all workspaces in TFS for the build machine and cleaning up the TFS cache in the build server.