Newline stripped from system parameter when accessed via msbuild runner

Hi,

 

I have a system parameter named test-categories-included which contains a newline separated set of NUnit test categories. The parameter is currently used within the a build step which uses the NUnit Runner to execute unit tests. The NUnit runner is using the param value to create a TSL string for NUnit categories.

The issue I have is that I now want to use the same variable within a MsBuild Runner step. When I access the system parameter from within my msbuild script by using $(test-categories-included) the newline chars have been removed and I have a single concatenated string containing my test categories.

My builds run of a TeamCity template which is used by hundreds of build configurations, so I don't want to have to change the values of each overridden parameter to be space (or other delimiter) separated.

Any idea how I can access the param newline separated?

 




0
1 comment
Avatar
Nikolay Pianikov

Hi Dav,

Unfortunately there is no simple way to do it. But you could use complex one:
For example this msbuild project
`
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="HttpGetData" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Url ParameterType="System.String" Required="true" />
<Username ParameterType="System.String" Required="true" />
<Password ParameterType="System.String" Required="true" />
<Data ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System"/>
<Using Namespace="System.IO"/>
<Using Namespace="System.Net"/>
<Code Type="Fragment" Language="cs">
<![CDATA[
using (WebClient client = new WebClient())
{
client.Credentials = new NetworkCredential(Username, Password);
Data = client.DownloadString(Url);
}
]]>
</Code>
</Task>
</UsingTask>

<Target Name="Build">
<HttpGetData
Url="http://MyTeamCityServer:8080/httpAuth/app/rest/buildTypes/id:SomeBuildConfigId/parameters/MyVar/value"
Username="TestUser"
Password="abc">
<Output PropertyName="MyParam" TaskParameter="Data" />
</HttpGetData>
<Message Text="$(MyParam)"/>
</Target>
</Project>
`

prints the multiline configuration parameter "MyVar" for the build configuration with id "SomeBuildConfigId/parameters"

0

Please sign in to leave a comment.