1

we are currently migrating from XAML build to vNext (TFS2017). The "normal" builds work fine, but the build for our LicenseManager does not work. The folder containing the LicenseManager source code can only be accessed from certain users. So I configured one vNext build agent, where the build service runs on an account that has access to the source code (like we did with the xaml build). I used Capabilities and Demands to force the LicenseManager build on that agent.

But the GetSources task does not download the source code of the LicenseManager. These are the commands that the GetSources task uses:

tf vc workspace /new /location:local /permission:Public ws_1_12 /collection:http://tfs:8080/tfs/DefaultCollection/ /loginType:OAuth /login:.,******** /noprompt
tf vc workfold /unmap /workspace:ws_1_12 $/ /collection:http://tfs:8080/tfs/DefaultCollection/ /loginType:OAuth /login:.,******** /noprompt
tf vc workfold /map /workspace:ws_1_12 $/TPA/BuildVNext/1.7 D:\b\a1\_w\1\s\TPA\BuildVNext\1.7 /collection:http://tfs:8080/tfs/DefaultCollection/ /loginType:OAuth /login:.,******** /noprompt
tf vc workfold /map /workspace:ws_1_12 $/TPA/LicenseMgr/dev/main D:\b\a1\_w\1\s\TPA\LicenseMgr\dev\main /collection:http://tfs:8080/tfs/DefaultCollection/ /loginType:OAuth /login:.,******** /noprompt
tf vc workfold /map /workspace:ws_1_12 $/TPA/DevTools/internal/BuildHelper/1.6 D:\b\a1\_w\1\s\TPA\DevTools\internal\BuildHelper\1.6 /collection:http://tfs:8080/tfs/DefaultCollection/ /loginType:OAuth /login:.,******** /noprompt
tf vc workfold /map /workspace:ws_1_12 $/TPA/DevTools/internal/ReferenceManager/1.9 D:\b\a1\_w\1\s\TPA\DevTools\internal\ReferenceManager\1.9 /collection:http://tfs:8080/tfs/DefaultCollection/ /loginType:OAuth /login:.,******** /noprompt
tf vc workfold /map /workspace:ws_1_12 $/TPA/DevTools/external/MsBuild/ExtensionPack/4.0.9 D:\b\a1\_w\1\s\TPA\DevTools\external\MsBuild\ExtensionPack\4.0.9 /collection:http://tfs.:8080/tfs/DefaultCollection/ /loginType:OAuth /login:.,******** /noprompt
tf vc get /version:178702 /recursive /overwrite D:\b\a1\_w\1\s /loginType:OAuth /login:.,******** /noprompt

All folder except 'LicenseMgr\dev\main' (which is the one with restricted access) get downloaded. But when I open VisualStudio, select the workspace that was created during the build, and select "Get Latest", it does download the code without any problems.

Any help appreciated!

Best Regards Bernd

edit: I have added a simple batch script to the d: drive of the build computer and run that script after the GetSources task was done. This did download all the sources!!!

This is the script:

tf vc workspace /new /location:local /permission:Public %BUILD_REPOSITORY_TFVC_WORKSPACE% /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt
tf vc workfold /unmap /workspace:%BUILD_REPOSITORY_TFVC_WORKSPACE% $/ /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt
tf vc workfold /map /workspace:%BUILD_REPOSITORY_TFVC_WORKSPACE% $/TPA/BuildVNext/1.7 D:\b\a1\_w\1\s\TPA\BuildVNext\1.7 /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt
tf vc workfold /map /workspace:%BUILD_REPOSITORY_TFVC_WORKSPACE% $/TPA/DevTools/internal/BuildHelper/1.6 %BUILD_SOURCESDIRECTORY%\TPA\DevTools\internal\BuildHelper\1.6 /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt
tf vc workfold /map /workspace:%BUILD_REPOSITORY_TFVC_WORKSPACE% $/TPA/DevTools/internal/ReferenceManager/1.9 %BUILD_SOURCESDIRECTORY%\TPA\DevTools\internal\ReferenceManager\1.9 /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt
tf vc workfold /map /workspace:%BUILD_REPOSITORY_TFVC_WORKSPACE% $/TPA/DevTools/external/MsBuild/ExtensionPack/4.0.9 %BUILD_SOURCESDIRECTORY%\TPA\DevTools\external\MsBuild\ExtensionPack\4.0.9 /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt
tf vc workfold /map /workspace:%BUILD_REPOSITORY_TFVC_WORKSPACE% $/TPA/LicenseMgr/dev/main %BUILD_SOURCESDIRECTORY%\TPA\LicenseMgr\dev\main /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt
tf vc get /version:%BUILD_SOURCEVERSION% /recursive /overwrite %BUILD_SOURCESDIRECTORY% /noprompt

As I said, this did download all the sources, but have a look at the error messages, especially the account information of the workspace:

D:\b\a1\_w\1\s>tf vc workspace /new /location:local /permission:Public ws_1_12 /collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt 
The path D:\b\a1\_w\1\s\TPA\BuildVNext\1.7 is already mapped in workspace ws_1_12;Build\beb2741f-e779-4a6f-a20e-033796fec5b7.

D:\b\a1\_w\1\s>tf vc workfold /unmap /workspace:ws_1_12 $/ /collection:/collection:http://tfs.net:8080/tfs/DefaultCollection//noprompt 
TF14061: The workspace ws_1_12;Build_LicenseMgr does not exist.

D:\b\a1\_w\1\s>tf vc workfold /map /workspace:ws_1_12 $/TPA/BuildVNext/1.7 D:\b\a1\_w\1\s\TPA\BuildVNext\1.7 /collection:/collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt 
TF14061: The workspace ws_1_12;Build_LicenseMgr does not exist.

D:\b\a1\_w\1\s>tf vc workfold /map /workspace:ws_1_12 $/TPA/DevTools/internal/BuildHelper/1.6 D:\b\a1\_w\1\s\TPA\DevTools\internal\BuildHelper\1.6 /collection:/collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt 
TF14061: The workspace ws_1_12;Build_LicenseMgr does not exist.

D:\b\a1\_w\1\s>tf vc workfold /map /workspace:ws_1_12 $/TPA/DevTools/internal/ReferenceManager/1.9 D:\b\a1\_w\1\s\TPA\DevTools\internal\ReferenceManager\1.9 /collection:/collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt 
TF14061: The workspace ws_1_12;Build_LicenseMgr does not exist.

D:\b\a1\_w\1\s>tf vc workfold /map /workspace:ws_1_12 $/TPA/DevTools/external/MsBuild/ExtensionPack/4.0.9 D:\b\a1\_w\1\s\TPA\DevTools\external\MsBuild\ExtensionPack\4.0.9 /collection:/collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt 
TF14061: The workspace ws_1_12;Build_LicenseMgr does not exist.

D:\b\a1\_w\1\s>tf vc workfold /map /workspace:ws_1_12 $/TPA/LicenseMgr/dev/main D:\b\a1\_w\1\s\TPA\LicenseMgr\dev\main /collection:/collection:http://tfs.net:8080/tfs/DefaultCollection/ /noprompt 
TF14061: The workspace ws_1_12;Build_LicenseMgr does not exist.

D:\b\a1\_w\1\s>tf vc get /version:178749 /recursive /overwrite D:\b\a1\_w\1\s /noprompt 
D:\b\a1\_w\1\s\TPA\LicenseMgr\dev:
Getting main

edit2: To make my build work I just need on single line in the batch script:

tf vc get /version:%BUILD_SOURCEVERSION% /recursive /overwrite %BUILD_SOURCESDIRECTORY% /noprompt

So the /loginType:OAuth in the original GetSources task is causing the problem for me. The same command without the /loginType does work!

PainElemental
  • 687
  • 6
  • 14

2 Answers2

1

Seems the issue is still related to the permission. Suggest you double check the related account permission, also give it local admin permission on the build agent.

You could also disable the default get source steps in the build definition. And use your own script to do the get source/pull files to see if you get the same situation. How to, please follow: Is it able to ignore/disable the first step Get source in vNext Build?

Write a powershell script to do the entire get source option and use the account which have enough permission to pull down the limited LicenseManager folder.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • 1
    While this might work, doesn't it require much more manual work? The "Build Solution"-step and "Publish Artefact"-step will also have to be adapted. P.S.: The account does have local admin rights. – PainElemental Jan 26 '18 at 13:22
  • @PainElemental You could ignore the build and publish step first, just check if the files could be pull down through that way. This will narrow if the issue is related to your build service account. Another way is using the build service account to run the tf command line to get files directly, see if it works. Also set the clean workspace = **true**, force it to get all files every time when the build triggered. All of above just try to helps narrow down the issue. – PatrickLu-MSFT Jan 26 '18 at 16:05
  • OK, so I found out that setting SyncSources to false is not an option, because then all the variables 'BUILD_SOURCESDIRECTORY', 'BUILD_SOURCEVERSION' etc. are not set. – PainElemental Jan 29 '18 at 08:42
  • 1
    I added a simple batch-script to the d:\ drive of the build computer that does the same as the GetSources-task, but not specifying a LoginType. This does work! It does download all the sources when I run this script right after the GetSources task in the build! – PainElemental Jan 29 '18 at 08:51
  • I cannot post a long comment. Please see my edit in the original Question. – PainElemental Jan 29 '18 at 09:07
  • @PainElemental According to this error info `TF14061: The workspace ws_1_12;Build_LicenseMgr does not exist.` To use the workfold command, you must be the owner of the specified or implied workspace or have the global Administer workspaces permission set to Allow. Seems your issue has been solved, always better when you fix it yourself; as you understand how it works!:) If my reply helped or gave a right direction. Appreciate for [marking it as an answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) which will also helps others in the community. – PatrickLu-MSFT Jan 30 '18 at 09:51
  • Yep, look like the "Project Collection Build Service" account is the owner of the workspace. Why is this account used and not the account that runs the build service on the build agent? Maybe I have to check if the "Project Collection Build Service" account has access rights to the LicenseManager source code... – PainElemental Jan 30 '18 at 14:06
  • @PainElemental Yes, you should confirm if the project collection build service account have enough permission on the LicenseManager source code. And seems the root cause is still related to the permission, just as I suggested to check. Usually this kind of issue, some pulled, some not pulled most related to access rights. Glad to here the issue fixed. – PatrickLu-MSFT Jan 31 '18 at 15:51
0

Finally found the root cause of the problem: In XAML builds the account that is configured to run the build service is also used to create the workspace and get the sources. In vNext builds the "Project Collection Build Service" is used to create the workspace and get the sources. The "Project Collection Build Service" account did not have access to the LicenseManager source code.

After giving the "Project Collection Build Service" account access rights to the LicenseManager source code, everything is working as it should :)

PainElemental
  • 687
  • 6
  • 14