Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio Online Build Fails GetTeamBuildNumber Task failed unexpectedly. #7

Open
johnkattenhorn opened this issue Oct 20, 2014 · 6 comments

Comments

@johnkattenhorn
Copy link

Why I try to use this excellent package with TFS Online I get this error.

C:\a\src.deploy\Variables.targets (30): The "GetTeamBuildNumber" task failed unexpectedly.
Microsoft.TeamFoundation.TeamFoundationServerUnauthorizedException: TF30063: You are not authorized to access https://xxxxx.visualstudio.com/defaultcollection.

I'm wondering if the account that the build agent is running with needs another permission that it doesn't get with the online version by default.

I'm queuing the build using the TFS Owners account (mine).

I'm not the strongest MSBuild guy so any debugging steps / suggestion would be most welcome.

@johnkattenhorn
Copy link
Author

This looks interesting:

http://msdn.microsoft.com/en-us/library/hh850448.aspx

Seem you can get the build number by using a built in environment variable (Maybe VS2013 only), I'm going to see if I can make this work, please stop me if I'm barking up the wrong tree :-)

@johnkattenhorn
Copy link
Author

I've found a solution:

If I amend my MSBuild arguments to the following:

/p:GenerateProjectSpecificOutputFolder=true /p:CreateRelease=true  /p:VersionNumber="$(TF_BUILD_BUILDNUMBER)"

This works fine with TFS Online, thanks goes to whoever wrote the target conditions which checks for this value and only runs the GetTeamBuildNumber task if it's empty.

@johnkattenhorn
Copy link
Author

On closure inspection I can see that the TeamBuildNumber.targets is designed to cater for this problem but something is broken as it doesn't return the building number from the line

<Output TaskParameter="TEAMBuildNumber" PropertyName="TF_BUILD_BUILDNUMBER" />for some reason.

My suggestion works but I guess it's a workaround for now.

@ducas
Copy link
Contributor

ducas commented Oct 20, 2014

Hi John,

Thanks for reporting this issue and your great feedback.

This project was written for VS2012 on-premise installations, which is why you have run into this issue. In VS2012 the TF_BUILD_BUILDNUMBER variable didn't exist, which is why we needed the targets for getting the build number from TFS' API.

The workaround you have provided is perfect!

I will see if I can make the MSBuild targets use TF_BUILD_BUILDNUMBER if it is available and get back to you.

Cheers!
Ducas

@johnkattenhorn
Copy link
Author

No problem, glad I could help.

@ColinDabritzViewpoint
Copy link

For those wrestling with Hosted TFS in Visual Studio online, the variable is BUILD_BUILDNUMBER.

Per https://msdn.microsoft.com/Library/vs/alm/Build/scripts/variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants