tag:help.appveyor.com,2012-11-13:/discussions/problems/14211-how-to-export-a-bacpac-from-sql-after-failing-unit-testsAppVeyor: Discussion 2018-08-25T02:28:56Ztag:help.appveyor.com,2012-11-13:Comment/452965572018-05-17T01:12:20Z2018-05-17T01:12:20ZHow to export a BACPAC from SQL after failing unit tests.<div><p>Can you link us to the build or provide yaml configuration and/or build log?</p></div>Owen McDonnelltag:help.appveyor.com,2012-11-13:Comment/452965572018-05-17T04:22:35Z2018-05-17T04:22:35ZHow to export a BACPAC from SQL after failing unit tests.<div><p><strong>@eric</strong> you can use <code>SqlPackage.exe</code> from any of those folders:</p>
<ul>
<li><code>C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin</code></li>
<li><code>C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin</code></li>
<li><code>C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin</code></li>
</ul>
<p>But I think that more productive would be to <a href="https://www.appveyor.com/docs/how-to/rdp-to-build-worker/">RDP</a> 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).</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/452965572018-05-22T00:55:44Z2018-05-22T00:55:44ZHow to export a BACPAC from SQL after failing unit tests.<div><p>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?</p>
<pre>
<code>after_test:
- 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=..."'
...
artifacts:
- path: default.zip
- path: UnitTests.bacpac</code>
</pre></div>erictag:help.appveyor.com,2012-11-13:Comment/452965572018-05-22T01:55:31Z2018-05-22T01:55:31ZHow to export a BACPAC from SQL after failing unit tests.<div><p>Artifact should be inside appveyor builds folder. and path to it should be relative to that folder. You can use <code>APPVEYOR_BUILD_FOLDER</code> <a href="https://www.appveyor.com/docs/environment-variables/">environment variable</a> when creating <code>.bacpac</code> file to ensure it is created in the right place.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/452965572018-05-22T17:59:10Z2018-05-22T17:59:10ZHow to export a BACPAC from SQL after failing unit tests.<div><p>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.</p>
<p>We've also tried using <code>appveyor PushArtifact</code> ps.... with no luck. No extra artifacts are showing up.</p></div>erictag:help.appveyor.com,2012-11-13:Comment/452965572018-05-22T18:06:21Z2018-05-22T18:06:21ZHow to export a BACPAC from SQL after failing unit tests.<div><p>Please provide us your build configuration in YAML format and link to the build.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/452965572018-05-23T18:02:26Z2018-05-23T18:02:26ZHow to export a BACPAC from SQL after failing unit tests.<div><p>We finally got it to work by moving everything to <code>on_finish</code>, adding <code>appveyor PushArtifact</code> and adding the artifact file name to the <code>artifacts</code> section.</p></div>erictag:help.appveyor.com,2012-11-13:Comment/452965572018-05-23T18:26:29Z2018-05-23T18:26:29ZHow to export a BACPAC from SQL after failing unit tests.<div><p>Good, thanks for the update.</p></div>Ilya Finkelshteyn