Search code examples
visual-studio-2019gitlab-ci-runner

Why did my automated Visual Studio builds suddenly stopped building?


I have a Visual Studio project that I have been automatically building in GitLab CI for quite some time without any issues. I'm building the solution simply with:

devenv.exe MySolution.sln /Build "Release|x64"

Today, the builds suddenly and silenty started to fail. I have made no changes at all and the build command provides no output either. What is going on?


Solution

  • The most likely cause for Visual Studio builds suddenly starting to fail is an expired Visual Studio license.

    Resolving silent build failures

    The reason you're not seeing any output is that you're invoking devenv.exe, which is not designed to output to stdout as it's a desktop application.

    In your build scripts, you're going to want to use devenv.com. Once you do so, you'll see the following output instead:

    Microsoft Visual Studio 2019 Version 16.8.3.
    Copyright (C) Microsoft Corp. All rights reserved.
    The license for Visual Studio has expired.
    The evaluation period for this product has ended.
    

    Resolving expired license

    On your build machine, open Visual Studio and check if the license is still valid. Note however, that you need to start Visual Studio with the same user account your build runner uses.

    For GitLab CI on a Windows machine, where it's running as a service, Visual Studio will run as the SYSTEM user. So you need to start is as the SYSTEM user as well.

    To do so, use psexec. For example:

    PsExec.exe -si "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.com"
    

    You will most likely be greeted by a dialog asking you to log in to update your license. Upon completion, your builds will be running smoothly again.