4

I'm using a Powershell build step and want to generate a file and have it included in the artifacts. Here's what I tried, but it doesn't appear:

param(
[parameter(Mandatory=$true)] [string]$controller
)
Write-Output "Controller: $controller"

$testsettingsXML = @"
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Remote" id="36b029f0-1e34-4c17-b7b1-3e6a0284a08e" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <RemoteController name="$controller" />
  <Execution location="Remote">
    <TestTypeSpecific>
      <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
        <AssemblyResolution>
          <TestDirectory useLoadContext="true" />
        </AssemblyResolution>
      </UnitTestRunConfig>
    </TestTypeSpecific>
    <AgentRule name="AllAgentsDefaultRole">
    </AgentRule>
  </Execution>
  <Properties />
</TestSettings>
"@

#write the testsettings file out to disk.
$testsettingsXML | Out-File -FilePath "./remotehack.testsettings" -Encoding utf8

I did a similar thing in a metarunner and it worked just fine. Why not here?

Ben Power
  • 1,786
  • 5
  • 27
  • 35
  • Is it possible the ps script is not executed in the location you would expected without set-location. What if you make it a full path for the -FilePath for a test run and see if the file would appear? – Kai Zhao Apr 23 '16 at 01:37
  • Have you tried to invoke this script manually on the same agent under the same user? Does it run successfully? – Alina Mishina Apr 25 '16 at 12:39

1 Answers1

0

The issues were three-fold.

  1. Last line of the Powershell should have looked like this:

    $testsettingsXML | Out-File -FilePath "remotehack.testsettings" -Encoding utf8

  2. I didn't include remotehack.testsettings/remotehack.testsettings as an Artifact Dependency

  3. I didn't include the Artifact Path "remotehack.testsettings" under General Settings.

A few newbie mistakes.

Ben Power
  • 1,786
  • 5
  • 27
  • 35