How to export a BACPAC from SQL after failing unit tests.

eric's Avatar


16 May, 2018 11:30 PM

I've got a unit test that is failing for reasons I cannot figure out. Only in my AppVeyor builds, not locally. I'd like to inspect the SQL state after the unit tests are complete, so I'd like to export a BACPAC as a build artifact after is is done, if the build fails.

  1. Support Staff 1 Posted by Owen McDonnell on 17 May, 2018 01:12 AM

    Owen McDonnell's Avatar

    Can you link us to the build or provide yaml configuration and/or build log?

  2. Support Staff 2 Posted by Ilya Finkelshte... on 17 May, 2018 04:22 AM

    Ilya Finkelshteyn's Avatar

    @eric you can use SqlPackage.exe from any of those folders:

    • C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin
    • C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin
    • C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin

    But I think that more productive would be to RDP to build VM and debug tests manually. Note however that environment variables from build session are not available in RDP session so you need to re-create some of them manually (if your tests depend on them).

  3. 3 Posted by eric on 22 May, 2018 12:55 AM

    eric's Avatar

    Thanks for the tips! I've gone and added these to my yaml file, but I get no extra file attached to my build artifacts. Any ideas?

      - cmd: '"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\sqlpackage.exe" /Action:Export /TargetFile:"C:\Builds\...\$(appveyor_build_version)\UnitTests.bacpac" /SourceConnectionString:"Server=(local)\SQL2017;Initial Catalog=UnitTests;User ID=...;Password=..."'
    - path:
    - path: UnitTests.bacpac
  4. Support Staff 4 Posted by Ilya Finkelshte... on 22 May, 2018 01:55 AM

    Ilya Finkelshteyn's Avatar

    Artifact should be inside appveyor builds folder. and path to it should be relative to that folder. You can use APPVEYOR_BUILD_FOLDER environment variable when creating .bacpac file to ensure it is created in the right place.

  5. 5 Posted by eric on 22 May, 2018 05:59 PM

    eric's Avatar

    it still doesn't seem to be running my commands at all. I don't see anything, error or cmd line output in the build log at all. Should it be there? What am I missing? I can verify that I can log into the build VM and run the command just fine. but no dice when I add it to the artifact output.

    We've also tried using appveyor PushArtifact ps.... with no luck. No extra artifacts are showing up.

  6. Support Staff 6 Posted by Ilya Finkelshte... on 22 May, 2018 06:06 PM

    Ilya Finkelshteyn's Avatar

    Please provide us your build configuration in YAML format and link to the build.

  7. 7 Posted by eric on 23 May, 2018 06:02 PM

    eric's Avatar

    We finally got it to work by moving everything to on_finish, adding appveyor PushArtifact and adding the artifact file name to the artifacts section.

  8. Support Staff 8 Posted by Ilya Finkelshte... on 23 May, 2018 06:26 PM

    Ilya Finkelshteyn's Avatar

    Good, thanks for the update.

  9. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:28 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