for construct in yml causes error: build phase is set to "MSBuild" mode (default)

Dale Phurrough's Avatar

Dale Phurrough

09 Jul, 2019 01:55 PM

Hello. When a for: construct is included in my appveyor.yml and I start a manual build, I receive the following error on line 4 of the console.

The build phase is set to "MSBuild" mode (default), but no Visual Studio project or solution files were found in the root directory. If you are not building Visual Studio project switch build mode to "Script" and provide your custom build command.

I request insight from the community or the support team. Ideas, workaround, or bug?

This is not the git auth problems of other issue posts with this error. Instead, the cause of this error is the inclusion of a for: construct in my appveyor.yml. If I remove this construct, the project builds as expected. This is the construct:

for:
  -
    matrix:
      except:
        - GROUP_OS_DISTTAG: all
        - GROUP_OS_DISTTAG: pull-request
          OS_DISTTAG: ubuntu-14.04
        - GROUP_OS_DISTTAG: pull-request
          OS_DISTTAG: archlinux
    branches:
      except:
        - /.*/

My intention with this construct is to skip all jobs that...

UI defined plain env var GROUP_OS_DISTTAG=all
  or
(UI defined plain env var GROUP_OS_DISTTAG=pull-request) and (yml defined matrix var OS_DISTTAG=ubuntu-14.04)
  or
(UI defined plain env var GROUP_OS_DISTTAG=pull-request) and (yml defined matrix var OS_DISTTAG=archlinux)

The full appveyor.yml validates at https://ci.appveyor.com/tools/validate-yaml

  1. 1 Posted by Dale Phurrough on 09 Jul, 2019 03:28 PM

    Dale Phurrough's Avatar

    This alternate for construct also causes the same error:

    for:
      -
        matrix:
          only:
            - GROUP_OS_DISTTAG: pull-request
              OS_DISTTAG: ubuntu-14.04
        only_commits:
          author: /./
      -
        matrix:
          only:
            - GROUP_OS_DISTTAG: pull-request
              OS_DISTTAG: archlinux
        only_commits:
          author: /./
      -
        matrix:
          except:
            - GROUP_OS_DISTTAG: all
        skip_commits:
          author: /.*/
    
  2. 2 Posted by Dale Phurrough on 10 Jul, 2019 04:36 PM

    Dale Phurrough's Avatar

    I believe there is something fundamental not working with the for construct.
    I now have a simple for taken almost directly from the AppVeyor documentation

    for:
      -
        matrix:
          only:
            - DOCKERHUBUSER: user1
    
        skip_commits:
          author: /John|Jack/
    

    This fails with the same error.
    Removing this construct, the build works as expected.

  3. Support Staff 3 Posted by Ilya Finkelshte... on 10 Jul, 2019 09:34 PM

    Ilya Finkelshteyn's Avatar

    Hi Dale,

    Sorry for the late reply.

    First let me please explain nature of this specific error. When build phase started, AppVeyor behaves in one of the two ways. If build_script exists, it is being executed. If not, AppVeyor runs in MSBuild mode and trying to find Visual Studio solution or project. If none is found, AppVeyor throws this error.

    I do not see your full appveyor.yml, but I believe that with for construct, resultant build configuration lucks build_script, so AppVeyor switches to MSBuild mode and you do not have any .sln or .csproj files in your project. If you share full appveyor.yml, we can explain with more specifics.

    Also I think that you have different expectation regarding for construct functionality, that what it actually has. I think that you believe that for.matrix.except construct excludes specific job altogether and for.matrix.only construct excludes all others. This is not true, those constructs were implementing for specializing configurations, not white- or black-listing them. E.g. you can set specific build_script for some subset of jobs in the matrix.

    Later we indeed adjusted this construct to make it skip jobs altogether by "marring" for construct with various conditions. However this approach will not work for you because I believe (from another post) you need to skip specific jobs in the matrix based in the project, correct?

    We hit similar problem already number of times (even in our own internal builds) and have some ideas. But for now we use and recommend others Exit-AppveyorBuild at init stage with some IFs, but this still starts build and then exits, so it is quite dirty workaround. For your case, you can condition it with APPVEYOR_PROJECT_NAME environment variable.

  4. 4 Posted by Dale Phurrough on 11 Jul, 2019 04:15 PM

    Dale Phurrough's Avatar

    I've isolated a repo case where the for clause is not behaving as documented. I've so far found two separate issues, I'll focus on the for behavior in this thread.

    I do request clarity on the resolution of this issue:

    1. If it is my mistake in formatting/fields of the yml, please do suggest corrections.
    2. If it is a AppVeyor bug in part or all of the for construct, please also tell me so that I know what to use/not or to avoid the entire for construct functionality.

    Setup

    1. Create a local git repo in an empty directory
    2. Make a first commit into the master branch. Doesn't matter the content.
    3. Checkout a new branch called repo1
    4. Create a subdirectory within the top folder called ci
    5. Save the below yml content into ci/appveyor.yml
    6. Stage and commit these changes into your git repo
    7. Push this git repo and the repo1 branch to a public repo on github
    8. Create a new project on appveyor
    9. authorize this project to your github repo
    10. Set and Save the following project settings
      • default branch = repo1
      • custom yml filename = ci/appveyor.yml
      • do not build on Push events = selected

    Repo

    1. Go to the 'current build' tab of the appveyor project just created
    2. Click 'new build'

    Result

    Three jobs are created and run for: ubuntu-14.04, ubuntu-16.04, ubuntu-18.04

    Expected

    Two jobs created and run for only: ubuntu-14.04, ubuntu-18.04

    appveyor.yml

    version: 1.0.{build}
    image: Ubuntu1804
    environment:
      matrix:
        - OS_DISTTAG: ubuntu-14.04
        - OS_DISTTAG: ubuntu-16.04
        - OS_DISTTAG: ubuntu-18.04
    
    install:
    - sh: |
        echo "I am the install script for OS_DISTTAG=${OS_DISTTAG}"
    
    build_script:
    - sh: |
        echo "I am the build_script script for OS_DISTTAG=${OS_DISTTAG}"
    
    test_script:
    - sh: |
        echo "I am the test_script script for OS_DISTTAG=${OS_DISTTAG}"
    
    for:
      -
        matrix:
          only:
            - OS_DISTTAG: ubuntu-16.04
    
        only_commits:
          author: RareAuthor1
    

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac