"The license for Visual Studio has expired." when compiling with Visual Studio from TFS build

Figured it out. If I register Visual Studio as me, then I can build. If I go to the MSDN site and get a product key (https://msdn.microsoft.com/en-us/subscriptions/keys/) and then in Visual Studio go to "Unlock with Product Key" and enter that key, now anyone (include the TFS Build Agent) can build.

Update

New url for Key: https://my.visualstudio.com/ProductKeys


We had a similar issue. Exact same scenario where we are using devenv.com because we are compiling SSIS projects.

It only differs in that we are using Visual Studio Team System Agents for the online offering of TFS to do builds and that we could not retrieve a key using our MSDN licensing. Instead we would receive a popup dialog stating A product key is not offered with this edition of Visual Studio. To unlock the product, you must sign in using the login associated with your active Visual Studio subscription. By signing in, your IDE settings will sync across devices, and you can connect to online developer services.

We had to remove the agent under the NT AUTHORITY\NETWORK SERVICE account and then install it again under an account where we could log in as that account, open Visual Studio, and have one of us sign-in in the Visual Studio client user their credentials.

This fixed the problem and now our builds are completing running under the service account.

Steps

  • Create local account or use domain account, for example domain\tfsservice
  • Log into build machine with that account, launch Visual Studio, sign-in in the Visual Studio client using credentials of someone who has valid license
  • Re-configure the agent by 1st removing it via config.cmd remove from an administrator command prompt
  • Then 2nd use config.cmd to re-configure the agent using the local or domain account instead of the NT AUTHORITY\NETWORK SERVICE account