-
Notifications
You must be signed in to change notification settings - Fork 19
/
VS2010ExpressSpecFlow.xml
106 lines (88 loc) · 4.07 KB
/
VS2010ExpressSpecFlow.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="C:\Program Files\MSBuild\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<PropertyGroup>
<BuildDependsOn>
GetProjectFilesFromProjectFilesProperty;
GetProjectFilesFromSolutionProperty;
MakeCopiesOfProjectFiles;
SpecFlow;
AddSpecFlowCSFilesToProject;
BuildProjects;
NUnit;
DeleteCopiedFiles;
</BuildDependsOn>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="$(BuildDependsOn)">
</Target>
<!-- The ProjectFiles property is set and there are no items, ie from the Solution building -->
<Target Name="GetProjectFilesFromProjectFilesProperty" Condition="'$(ProjectFiles)'!='' And '@(ProjectFiles)'==''">
<Message Text="GetProjectFilesFromProjectFilesProperty" Importance="high" />
<ItemGroup>
<ProjectFiles Include="$(ProjectFiles)" />
</ItemGroup>
</Target>
<!-- When there is a solution file, get the projects contained in the solution -->
<Target Name="GetProjectFilesFromSolutionProperty" Condition="'$(Solution)'!=''">
<Message Text="GetProjectFilesFromSolutionProperty" Importance="high" />
<GetSolutionProjects Solution="$(Solution)">
<Output ItemName="ProjectFiles" TaskParameter="Output"/>
</GetSolutionProjects>
</Target>
<Target Name="MakeCopiesOfProjectFiles" Condition="'@(ProjectFiles)'!=''">
<Copy
SourceFiles="@(ProjectFiles)"
DestinationFiles="@(ProjectFiles->'%(fullpath).copy')"
SkipUnchangedFiles="false"
ContinueOnError="false">
<Output ItemName="CopiedProjects" TaskParameter="CopiedFiles" />
</Copy>
</Target>
<!-- Run the CopiedProjects files through SpecFlow -->
<Target Name="SpecFlow" Condition="'@(CopiedProjects)'!=''" Outputs="%(CopiedProjects.fullpath)" >
<Exec Command='SpecFlow generateall "%(CopiedProjects.fullpath)"' />
</Target>
<!-- Build the CopiedProjects -->
<Target Name="BuildProjects" Condition="'@(CopiedProjects)'!=''" >
<MSBuild Projects="@(CopiedProjects)" Properties="Configuration=Debug">
<Output ItemName="OutputDLLs" TaskParameter="TargetOutputs" />
</MSBuild>
<Message Text="@(OutputDLLs)" Importance="high" />
</Target>
<Target Name="AddSpecFlowCSFilesToProject" Outputs="%(CopiedProjects.fullpath)" Condition="'@(CopiedProjects)'!=''" >
<XmlRead Prefix="n"
Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
XPath="/n:Project/n:ItemGroup/n:Content/@Include"
XmlFileName="%(CopiedProjects.fullpath)">
<Output TaskParameter="Value" PropertyName="BuildTargets" />
</XmlRead>
<TextString TaskAction="Split" String1="$(BuildTargets)" String2=";">
<Output ItemName="out" TaskParameter="Strings"/>
</TextString>
<RegexMatch
Input="%(out.Identity)"
Expression=".*\.feature">
<Output ItemName ="Features" TaskParameter="Output" />
</RegexMatch>
<!-- Add project filepath to each Feature -->
<CreateItem
Include="@(Features)"
AdditionalMetadata="FName=%(CopiedProjects.fullpath)">
<Output TaskParameter="Include" ItemName="MySourceItemsWithMetadata"/>
</CreateItem>
<FileUpdate
Files='%(MySourceItemsWithMetadata.FName)'
Regex='(?<Space>\s*)(?<Compile><\s*Compile\s+Include=".+"\s*/\s*>\s*)(?<ItemGroup>\s*</ItemGroup>)'
ReplacementText='${Compile}<Compile Include="%(MySourceItemsWithMetadata.Identity).cs" />${ItemGroup}' />
</Target>
<Target Name="NUnit" Condition="'@(OutputDLLs)'!=''" >
<TextString TaskAction="Split" String1="@(OutputDLLs)" String2=";">
<Output ItemName="out2" TaskParameter="Strings"/>
</TextString>
<Exec Command='NUnit "%(out2.Identity)" /run' />
</Target>
<!-- Cleanup, Remove the CopiedProjects -->
<Target Name='DeleteCopiedFiles' Condition="'@(CopiedProjects)'!=''">
<Delete Files="@(CopiedProjects)" />
</Target>
</Project>