I'd like to create a XML file within a MSBuild task.
I have a list of files:
<CreateItem Include="$(TestsAssembliesOutputDir)\Emidee.*.Tests.dll">
<Output ItemName="TestsAssemblies" TaskParameter="Include" />
</CreateItem>
I'd like to create a XML which would look like:
<?xml version="1.0" encoding="utf-8"?>
<xunit>
<assemblies>
<assembly filename="PATH OF FILE #1" shadow-copy="true" />
<assembly filename="PATH OF FILE #2" shadow-copy="true" />
</assemblies>
</xunit>
How can I achieve that?
Thanks in advance
Mike
The Microsoft Build Engine is a platform for building applications. This engine, which is also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software.
To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.
Quick and dirty...
<Target Name="CreateXml">
<ItemGroup>
<TestAssembly Include="$(TestsAssembliesOutputDir)\Emidee.*.Tests.dll" />
<Line Include="line01"><Text><xunit></Text></Line>
<Line Include="line02"><Text><assemblies></Text></Line>
<Line Include="line03"><Text><assembly filename="%(TestAssembly.Identity)" shadow-copy="true" /></Text></Line>
<Line Include="line04"><Text></assemblies></Text></Line>
<Line Include="line05"><Text></xunit></Text></Line>
<LineText Include="%(Line.Text)" />
</ItemGroup>
<WriteLinesToFile
File="out.xml"
Lines="@(LineText)"
Overwrite="true"
/>
</Target>
Left as an exercise for you
You could also use the following in WriteLinesToFile and omit the synthesized @(LineText)
Lines="@(Line->'%(Text)')"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With