Automated .NET Core tests fail to run if the "Any CPU" platform is explicitly specified

Jarl's Avatar


07 Mar, 2018 05:44 PM

When running automated tests under .NET Core (using dotnet test, or via specifying assemblies in appveyor.yml), the test run fails because the output directory of the project does not match the search directory of the test runner.

The binaries reside in <projectname>/bin/<configuration/, which the test runner looks in <projectname>/bin/Any CPU/<configuration>, and therefore fails.

I've included a log from one of my runs where this issue presents itself.

  1. 1 Posted by Ilya Finkelshte... on 08 Mar, 2018 12:38 AM

    Ilya Finkelshteyn's Avatar

    Yes, this is know issue it is tracked here. Will force resolution.

  2. 2 Posted by Jarl on 08 Mar, 2018 08:20 AM

    Jarl's Avatar

    Are there any known workarounds?

  3. 3 Posted by Ilya Finkelshte... on 09 Mar, 2018 08:18 AM

    Ilya Finkelshteyn's Avatar

    I still have no really full understanding of the problem, but it seems that resetting platform environment variable to AnyCpu (instead of Any Cpu) helps. So you can use test script (instead of automatic detection) and reset that variable before test command (if it is initially Any Cpu). But as I said there are not full problem understanding and no guarantee that this workaround is a proper one. If you decide to go this path, this it is better to reset this variable back after test command to stay on the safe side.

  4. 4 Posted by Jarl on 11 Mar, 2018 09:27 PM

    Jarl's Avatar

    I haven't been able to work around the issue by setting or clearing the variable. Are there any other ways to approach this?

  5. 5 Posted by Ilya Finkelshte... on 12 Mar, 2018 06:27 PM

    Ilya Finkelshteyn's Avatar

    It is fixed, no workaround needed. Please let us know if you still have this issue.

  6. 6 Posted by Jarl on 12 Mar, 2018 10:09 PM

    Jarl's Avatar

    My projects are still failing because of this. Furthermore, I have the same issue on Travis, and I'd like to know what you're using as a workaround.

  7. 7 Posted by Ilya Finkelshte... on 12 Mar, 2018 10:28 PM

    Ilya Finkelshteyn's Avatar

    We add /property:Platform=AnyCPU if we see that platform is Any CPU. Please share link to your problem build (or build log), and configuration in YAML format.

  8. 8 Posted by Jarl on 12 Mar, 2018 10:34 PM

    Jarl's Avatar

    This is the latest build on the failing branch:

    The source code of the project is available here, and the appveyor.yml file (along with the scripts it calls) is in the root and /scripts folder:

    Where is that switch added?

  9. 9 Posted by Ilya Finkelshte... on 12 Mar, 2018 10:40 PM

    Ilya Finkelshteyn's Avatar

    Subject of this discussion (Automated .NET Core tests...) and linked GitHub issue are about automated tests. Which are tests discovered and executed automatically by AppVeyor. We have no control of what you do in custom test script, so you need to add this yourself.

    Side note: after_test works only if you have automated test mode (not test_script). If you use test script, put all that command there.

  10. 10 Posted by Jarl on 12 Mar, 2018 10:43 PM

    Jarl's Avatar

    That's all well and good, but where exactly are you adding that property switch? In the dotnet test command, or elsewhere?

  11. 11 Posted by Jarl on 12 Mar, 2018 10:44 PM

    Jarl's Avatar

    Also, after_test runs fine.

  12. 12 Posted by Ilya Finkelshte... on 12 Mar, 2018 10:53 PM

    Ilya Finkelshteyn's Avatar

    In the end of dotnet test, check this build.

    I am curious to see link to the build where after_test runs fine when test_script is present.

  13. 13 Posted by Jarl on 13 Mar, 2018 12:28 PM

    Jarl's Avatar

    It seems like my messages are getting automodded, so I've waited a while and am trying again.

    Thanks, that worked. My builds are now finishing. Here's one of the job logs where the after_test step runs fine:

  14. 14 Posted by Ilya Finkelshte... on 13 Mar, 2018 08:10 PM

    Ilya Finkelshteyn's Avatar

    Good it is working, and yes, I was wrong after_test script.

  15. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:27 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? 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