-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildSequence.targets
121 lines (98 loc) · 5.23 KB
/
BuildSequence.targets
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastBuildSequencePath>$(SolutionDir)$(SolutionName).lbs.zou</LastBuildSequencePath>
<ActualBuildSequencePath>$(SolutionDir)$(SolutionName).abs.zou</ActualBuildSequencePath>
<LastBuildSequenceContainsProject>true</LastBuildSequenceContainsProject>
<BuildSequenceIsLastProject>true</BuildSequenceIsLastProject>
</PropertyGroup>
<!--=========================================================================-->
<!-- Reset build sequence if associated solution changes -->
<Target Name="ResetBuildSequence"
Condition="'$(SolutionName)' != '*Undefined*'"
Inputs="$(SolutionPath)"
Outputs="$(LastBuildSequencePath)">
<Delete Files="$(LastBuildSequencePath);$(ActualBuildSequencePath)" />
</Target>
<Target Name="ReadBuildSequence"
Condition="'$(SolutionName)' != '*Undefined*'"
DependsOnTargets="ResetBuildSequence">
<!-- Clean obsolete stuff -->
<Delete Files="$(SolutionDir)$(SolutionName).bo.zou" />
<!-- Load last build sequence -->
<ReadLinesFromFile File="$(LastBuildSequencePath)" >
<Output TaskParameter="Lines" ItemName="_Temporary"/>
</ReadLinesFromFile>
<ItemGroup >
<LastBuildSequence Include="@(_Temporary)" />
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
<PropertyGroup>
<LastBuildSequenceContainsProject></LastBuildSequenceContainsProject>
<LastBuildSequenceContainsProject Condition="'@(LastBuildSequence)' != '' And @(LastBuildSequence->AnyHaveMetadataValue('Identity', '$(ProjectPath)'))">true</LastBuildSequenceContainsProject>
</PropertyGroup>
<!-- Load actual build sequence -->
<ReadLinesFromFile File="$(ActualBuildSequencePath)" >
<Output TaskParameter="Lines" ItemName="_Temporary"/>
</ReadLinesFromFile>
<ItemGroup >
<ActualBuildSequence Include="@(_Temporary)" />
<_Temporary Remove="@(_Temporary)" />
</ItemGroup>
<PropertyGroup >
<ActualBuildSequenceContainsProject Condition="'@(ActualBuildSequence)' != '' And @(ActualBuildSequence->AnyHaveMetadataValue('Identity', '$(ProjectPath)'))">true</ActualBuildSequenceContainsProject>
</PropertyGroup>
<!--<LogItems Items="@(LastBuildSequence)" Title="[R] LastBuildSequence" />
<LogItems Items="@(ActualBuildSequence)" Title="[R] ActualBuildSequence" />
<Message Importance="high" Text="ActualBuildSequenceContainsProject = $(ActualBuildSequenceContainsProject)" />-->
<!-- Reset actual build sequence if the current project is alreay inside -->
<ItemGroup >
<ActualBuildSequence Remove="@(ActualBuildSequence)" Condition="'$(ActualBuildSequenceContainsProject)' == 'true'"/>
</ItemGroup>
<!-- If actual minus last is not empty, there is a new project in the solution -->
<ItemGroup >
<_ActualMinusLast Include="@(ActualBuildSequence)" />
<_ActualMinusLast Remove="@(LastBuildSequence)" />
</ItemGroup>
<Error Condition="'@(_ActualMinusLast)' != ''" Text="Seems the project '$(ProjectPath)' is new to the solution: please rebuild (clean then build) it!" />
<!-- Add current project to actual build sequence -->
<ItemGroup>
<ActualBuildSequence Remove="$(ProjectPath)" />
<ActualBuildSequence Include="$(ProjectPath)" />
</ItemGroup>
<!-- Compare last and actual build sequences: if they contain the same elements we can consider that the current project is the last project of the solution build -->
<ItemGroup >
<_LastMinusActual Include="@(LastBuildSequence)" />
<_LastMinusActual Remove="@(ActualBuildSequence)" />
</ItemGroup>
<PropertyGroup >
<BuildSequenceIsLastProject></BuildSequenceIsLastProject>
<BuildSequenceIsLastProject Condition="'@(_LastMinusActual)' == ''">true</BuildSequenceIsLastProject>
</PropertyGroup>
<ItemGroup >
<_LastMinusActual Remove="@(_LastMinusActual)" />
<_ActualMinusLast Remove="@(_ActualMinusLast)" />
</ItemGroup>
<!--<LogItems Items="@(ActualBuildSequence)" Title="[U] ActualBuildSequence" />
<Message Importance="high" Text="BuildSequenceIsLastProject = $(BuildSequenceIsLastProject)" />-->
</Target>
<Target Name="WriteBuildSequence"
Condition="'$(SolutionName)' != '' And '$(SolutionName)' != '*Undefined*'"
DependsOnTargets="ReadBuildSequence">
<ItemGroup>
<LastBuildSequence Remove="$(ProjectPath)" />
<LastBuildSequence Include="$(ProjectPath)" />
</ItemGroup>
<WriteLinesToFile File="$(LastBuildSequencePath)"
Lines="@(LastBuildSequence)"
Overwrite="true" />
<WriteLinesToFile File="$(ActualBuildSequencePath)"
Lines="@(ActualBuildSequence)"
Overwrite="true" />
<!--<LogItems Items="@(LastBuildSequence)" Title="[W] LastBuildSequence" />
<LogItems Items="@(ActualBuildSequence)" Title="[W] ActualBuildSequence" />-->
</Target>
<Target Name="BuildSequenceClean" AfterTargets="AfterClean" Condition="'$(ZouInsideRebuild)' != 'true'">
<Delete Files="$(LastBuildSequencePath);$(ActualBuildSequencePath)" />
</Target>
</Project>