-
Notifications
You must be signed in to change notification settings - Fork 0
/
MetaCreator.targets
307 lines (273 loc) · 11.6 KB
/
MetaCreator.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<Project DefaultTarget='Disclamer' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
<Target Name='Disclamer'>
<Error Text='* MetaCreator.targets: You can not run MetaCreator.targets dirrectly. Please, include it into your project. MetaCreator injects to the building chain.' />
</Target>
<PropertyGroup>
<MetaCreatorVersion>1.7</MetaCreatorVersion>
<UseHostCompilerIfAvailable>False</UseHostCompilerIfAvailable>
</PropertyGroup>
<!-- Determine and try to fix double import -->
<PropertyGroup>
<MCImportedTwice Condition="'$(MCImported)'=='True'">True</MCImportedTwice>
<MCImported>True</MCImported>
<ItemsGroup Condition="'$(MCImportedTwice)'=='True'">
<Error Text="* MetaCreator.targets: Metacreator is imported twice! (Probably it is installed in the system and included into project file at the same time)" />
<!--
set flag and use it as a condition before injectors
<BuildDependsOn Remove="ShadowCopyWrapper;ExecuteMetaCreator" />
<CleanDependsOn Remove="CleanGeneratedFiles" />
-->
</ItemsGroup>
</PropertyGroup>
<!-- Determine dev mode -->
<PropertyGroup Condition="Exists('MetaCreator.sln')">
<DevMode>True</DevMode>
</PropertyGroup>
<PropertyGroup Condition="Exists('..\MetaCreator.sln')">
<DevMode>True</DevMode>
</PropertyGroup>
<PropertyGroup Condition="Exists('..\..\MetaCreator.sln')">
<DevMode>True</DevMode>
</PropertyGroup>
<PropertyGroup Condition='$(DevMode)!=True'>
<DevMode>False</DevMode>
</PropertyGroup>
<Choose>
<When Condition='$(DevMode)'>
<PropertyGroup>
<MC_Steps>
ShadowCopyWrapper;
GetMetaCreatorRealFullPath; <!-- Full path to MC are passed as input to wrapper task. It allows to detect changes in MetaCreator.dll during dev mode -->
ExecuteMetaCreatorWrapper;
</MC_Steps>
<DevCommonBinPath>$(SolutionDir)Bin\$(ConfigurationName)\</DevCommonBinPath>
<Wrapper>$(DevCommonBinPath)MSBuildWrapper.dll</Wrapper>
<WrapperCopy>$(DevCommonBinPath)MSBuildWrapper.copy.dll</WrapperCopy>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<MC_Steps>
ExecuteMetaCreator;
</MC_Steps>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup>
<MC_Build>Started</MC_Build>
<!--
Started - initial value of state
Requested - defined in before_BuildDependsOn injection
Performed - defined in ExecuteMetacreator, after ResolveReferencesDependsOn, if Requested
Done - defined in after_BuildDependsOn injection, check that requested build is performed and change state
-->
<CompileDependsOn>
MC_BeforeCompile_Aspect;
$(MC_Steps);
$(CompileDependsOn);
MC_AfterCompile_Aspect;
</CompileDependsOn>
<!--
<BuildDependsOn>
MC_BeforeCompile_Aspect;
$(CompileDependsOn);
MC_AfterCompile_Aspect;
</BuildDependsOn>
<ResolveReferencesDependsOn>
$(ResolveReferencesDependsOn);
$(MC_Steps);
</ResolveReferencesDependsOn>
-->
</PropertyGroup>
<!-- Import custom targets -->
<Import Project="$(MSBuildProjectDirectory)\..\..\..\..\..\..\..\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\..\..\..\..\..\..\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\..\..\..\..\..\..\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\..\..\..\..\..\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\..\..\..\..\..\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\..\..\..\..\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\..\..\..\..\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\..\..\..\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\..\..\..\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\..\..\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\..\..\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\..\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\..\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\..\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\..\MetaCreator.Custom.targets')"/>
<Import Project="$(MSBuildProjectDirectory)\MetaCreator.Custom.targets" Condition="Exists('$(MSBuildProjectDirectory)\MetaCreator.Custom.targets')"/>
<PropertyGroup Condition="'$(MetaCreatorDLL)'==''">
<MetaCreatorDLL Condition="'$(MetaCreatorRealFullPath)'!=''" >$(MetaCreatorRealFullPath)</MetaCreatorDLL>
<!-- <MetaCreatorDLL Condition="'$(MSBuildThisFileDirectory)'!=''">$(MSBuildThisFileDirectory)\MetaCreator.dll</MetaCreatorDLL> Net4.0 -->
<MetaCreatorDLL Condition="'$(MetaCreatorDLL)'==''">MetaCreator.dll</MetaCreatorDLL>
</PropertyGroup>
<Target Name='MC_BeforeCompile_Aspect'>
<PropertyGroup>
<MC_Build>Requested</MC_Build>
</PropertyGroup>
</Target>
<Target Name='MC_AfterCompile_Aspect'>
<Error Condition="'$(MC_Build)'!='Performed'" Text='* MetaCreator.targets: Assert: Build requested, but was not performed in building chain.' />
<PropertyGroup>
<MC_Build>Done</MC_Build>
</PropertyGroup>
</Target>
<PropertyGroup>
<CleanDependsOn>
CleanGeneratedFiles;
$(CleanDependsOn);
</CleanDependsOn>
</PropertyGroup>
<UsingTask Condition='$(DevMode)' AssemblyFile='$(WrapperCopy)' TaskName='MSBuildWrapper' />
<UsingTask Condition='!$(DevMode)' AssemblyFile='$(MetaCreatorDLL)' TaskName='MetaCreator.ExecuteMetaCreator' />
<!--Target Name="msg" BeforeTargets="ExecuteMetaCreatorWrapper;ExecuteMetaCreator;ShadowCopyWrapper">
<Message Text='* MetaCreator.targets: DevMode=$(DevMode)' Importance='high' />
<Error Text="* MetaCreator.targets: Targets have been imported twice in the project" Condition="'$(MCImportedTwice)'=='True'"/>
</Target-->
<Target Name='GetMetaCreatorRealFullPath' Condition="'$(MetaCreatorRealFullPath)'=='' Or '$(MetaCreatorDLL)'=='' ">
<Message Text='* MetaCreator.targets: Execute wrapper with GetMetaCreatorRealFullPath...' Importance='high'/>
<MSBuildWrapper
Task = 'MetaCreator.GetAssemblyPath, MetaCreator.dll'
Bin = '$(DevCommonBinPath)'
OutputParamNames = 'AssemblyFullPath; AssemblyDir'
>
<Output TaskParameter='OutputParam1' PropertyName='MetaCreatorRealFullPath' />
<Output TaskParameter='OutputParam2' PropertyName='MetaCreatorRealDir' />
</MSBuildWrapper>
<PropertyGroup>
<MetaCreatorDLL>$(MetaCreatorRealFullPath)</MetaCreatorDLL>
</PropertyGroup>
</Target>
<Target Name='ExecuteMetaCreatorWrapper'
Inputs='$(MetaCreatorDLL);
@(Meta);
@(None);
$(MSBuildAllProjects);
@(Compile);
@(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
@(ReferencePath);
@(CompiledLicenseFile);
@(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
$(ProjectPath);
@(CustomAdditionalCompileInputs);
'
Outputs='@(IntermediateAssembly)' >
<Message Text='* MetaCreator.targets: Execute wrapper with MetaCreator...' Importance='high'/>
<Error Condition="'$(MC_Build)'!='Requested'" Text='* MetaCreator.targets: Assert: Build requested, but was not performed in building chain.' />
<MSBuildWrapper
Task = 'MetaCreator.ExecuteMetaCreator, MetaCreator.dll'
Bin = '$(DevCommonBinPath)'
ArrayNames = 'Sources; References; ProjectPaths'
Array1 = '@(Compile); @(None)'
Array2 = '@(ReferencePath)'
Array3 = '$(ProjectPath)'
ParamNames = 'IsDevMode; IntermediateOutputPath; ProjDir; TargetFrameworkVersion; TargetsVersion; MLevel'
Param1 = 'True'
Param2 = '$(IntermediateOutputPath)'
Param3 = '$(ProjectDir)'
Param4 = '$(TargetFrameworkVersion)'
Param5 = '$(MetaCreatorVersion)'
Param6 = '$(MLevel)'
OutputArrayNames = 'AddFiles; RemoveFiles'
>
<Output TaskParameter='OutputArray1' ItemName='MCAddFiles' />
<Output TaskParameter='OutputArray2' ItemName='MCRemoveFiles' />
</MSBuildWrapper>
<ItemGroup>
<Compile Include='@(MCAddFiles)'/>
<Compile Remove='@(MCRemoveFiles)'/>
</ItemGroup>
<PropertyGroup>
<MC_Build>Performed</MC_Build>
</PropertyGroup>
</Target>
<Target
Name='ExecuteMetaCreator'
Inputs='
$(MetaCreatorDLL);
@(Meta);
@(None);
$(MSBuildAllProjects);
@(Compile);
@(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
@(ReferencePath);
@(CompiledLicenseFile);
@(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
$(ProjectPath);
$(MLevel);
@(CustomAdditionalCompileInputs);
'
Outputs='@(IntermediateAssembly)' >
<Message Text='* MetaCreator.targets: Execute MetaCreator (Targets v$(MetaCreatorVersion))...' Importance='high'/>
<Error Condition="'$(MC_Build)'!='Requested'" Text='* MetaCreator.targets: Assert: Buld requested, but was not performed in building chain.' />
<ExecuteMetaCreator
Sources = '@(Compile); @(None)'
References = '@(ReferencePath)'
ProjDir = '$(ProjectDir)'
ProjectPaths = '$(ProjectPath)'
MLevel = '$(MLevel)'
IntermediateOutputPath = '$(IntermediateOutputPath)'
TargetFrameworkVersion = '$(TargetFrameworkVersion)'
TargetsVersion = '$(MetaCreatorVersion)'
>
<Output TaskParameter='AddFiles' ItemName='MCAddFiles' />
<Output TaskParameter='RemoveFiles' ItemName='MCRemoveFiles' />
</ExecuteMetaCreator>
<ItemGroup>
<Compile Include='@(MCAddFiles)'/>
<Compile Remove='@(MCRemoveFiles)'/>
</ItemGroup>
<PropertyGroup>
<MC_Build>Performed</MC_Build>
</PropertyGroup>
</Target>
<Target
Name='ShadowCopyWrapper'
Inputs='$(Wrapper)'
Outputs='$(WrapperCopy)'>
<Message Text='* MetaCreator.targets: Shadow copy wrapper: $(Wrapper) $(WrapperCopy)' Importance='high' />
<Copy ContinueOnError='true' SourceFiles='$(Wrapper)' DestinationFiles='$(WrapperCopy)' />
<PropertyGroup>
<Wrapper>$(WrapperCopy)</Wrapper>
</PropertyGroup>
</Target>
<Target Name='CleanGeneratedFiles'>
<Message Text='* MetaCreator.targets: Clean' Importance='high'/>
<CreateItem Include='$(IntermediateOutputPath)**\*.g.cs'>
<Output TaskParameter='Include' ItemName='GeneratedFiles'/>
</CreateItem>
<!-- ANOTHER WAY v3.5
<ItemGroup>
<GeneratedFiles Include='$(IntermediateOutputPath)**\*.g.cs'/>
</ItemGroup>
-->
<!--
<Exec ContinueOnError='true' Command='attrib -r %(GeneratedFiles.Identity)' />
-->
<Delete ContinueOnError='true' Files='@(GeneratedFiles)'/>
</Target>
</Project>
<!--
<LightPersistModelGenerator
Sources = '@(None)'
IntermediateOutputPath = '$(IntermediateOutputPath)'
ProjectDir = '$(ProjectDir)'
>
<Output TaskParameter='Include' ItemName='Compile' />
</LightPersistModelGenerator>
-->
<!--
<UsingTask AssemblyFile='$(MetaCreatorDll)' TaskName='MetaCreator.ExecuteMetaCreator' />
<Target Name='ExecuteMetaCreator'>
<Message Text='* MetaCreator.targets: Execute...' Importance='high'/>
<MetaCreator.ExecuteMetaCreator Sources='@(Compile)' IntermediateOutputPath='$(IntermediateOutputPath)' >
<Output TaskParameter='AddFiles' ItemName='Compile' />
<Output TaskParameter="AddFiles" ItemName="MCAddFiles" />
<Output TaskParameter="RemoveFiles" ItemName="MCRemoveFiles" />
</MetaCreator.ExecuteMetaCreator>
<ItemGroup>
<Compile Remove="@(MCRemoveFiles)"/>
</ItemGroup>
</Target>
-->