forked from autofac/Autofac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.proj
490 lines (441 loc) · 24.9 KB
/
default.proj
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
<?xml version="1.0" encoding="utf-8"?>
<Project InitialTargets="__EnvironmentSetup" DefaultTargets="All" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<!--
[Standard Build]
msbuild default.proj
[Production/Release Build]
msbuild default.proj /p:Production=true
[Mock MyGet CI Build]
msbuild default.proj /p:Production=true /p:MyGetBuild=true /p:BuildCounter=1
Control version numbers through PackageVersions.proj
-->
<PropertyGroup>
<!-- BuildDirectory is the root of where build output goes. -->
<BuildDirectory>$(MSBuildProjectDirectory)\build_output</BuildDirectory>
<!-- Setting the path to MSBuildCommunityTasks to . allows you to check them in; otherwise you must install them. -->
<MSBuildCommunityTasksPath>.</MSBuildCommunityTasksPath>
<!-- PackageInstallDirectory is where NuGet installs the set of dependencies. -->
<PackageInstallDirectory>$(MSBuildProjectDirectory)\packages</PackageInstallDirectory>
<!-- Set this to false via command-line when debugging/troubleshooting NuGet packaging. -->
<DeleteNuGetStaging Condition="'$(DeleteNuGetStaging)' == ''">true</DeleteNuGetStaging>
<NuGetCommandLinePath>$(MSBuildProjectDirectory)\lib\NuGet\NuGet.exe</NuGetCommandLinePath>
</PropertyGroup>
<PropertyGroup Condition="'$(MyGetBuild)' == ''">
<!-- Determines if the build is running under MyGet Build Services. -->
<MyGetBuild Condition="'$(BuildRunner)' == 'MyGet'">true</MyGetBuild>
<MyGetBuild Condition="'$(BuildRunner)' != 'MyGet'">false</MyGetBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildConfiguration)' == ''">
<!-- Unless otherwise specified, dev build is Debug, production build is Release. -->
<BuildConfiguration Condition="'$(Production)' == 'true'">Release</BuildConfiguration>
<BuildConfiguration Condition="'$(Production)' != 'true'">Debug</BuildConfiguration>
</PropertyGroup>
<PropertyGroup Condition="'$(Package)' == ''">
<!-- Unless otherwise specified, dev build will not run packaging, production build will. -->
<Package Condition="'$(Production)' == 'true'">true</Package>
<Package Condition="'$(Production)' != 'true'">false</Package>
</PropertyGroup>
<PropertyGroup Condition="'$(Document)' == ''">
<!-- Unless otherwise specified, dev build will not build documentation, production build will. -->
<Document Condition="'$(Production)' == 'true' And '$(MyGetBuild)' == 'false'">true</Document>
<Document Condition="'$(Production)' != 'true'">false</Document>
</PropertyGroup>
<ItemGroup>
<!-- SolutionFile is the solution to build. Technically we could add more if needed. -->
<SolutionFile Include="$(MSBuildProjectDirectory)\Autofac.sln" />
</ItemGroup>
<Import Project="$(MSBuildProjectDirectory)\lib\BuildTasks\MSBuild.Community.Tasks.targets" />
<Import Project="$(MSBuildProjectDirectory)\PackageVersions.proj" />
<!--
-
- TARGETS are in alpha order. "Private" targets that act as "subroutines" start with
- double-underscore. The "All" target is the primary entry point.
-
-->
<Target Name="All">
<CallTarget Targets="UpdateVersion;CleanNuGet" Condition="'$(Production)' == 'true'" />
<CallTarget Targets="Clean;Compile;Test" />
<CallTarget Targets="Analyze" Condition="'$(MyGetBuild)' == 'false'" />
<CallTarget Targets="Package" Condition="'$(Package)' == 'true'" />
<CallTarget Targets="Document" Condition="'$(Document)' == 'true'" />
<Message Importance="high" Text="IMPORTANT: If you are planning to release this build, be sure to run the AppCert tests in Core/Tests/Autofac.Tests.AppCert to ensure Windows Store compatibility." />
</Target>
<Target Name="Analyze">
<!--
SecAnnotate generates a ton of false warnings so it only runs in production
builds. Other analysis can run in regular builds.
-->
<CallTarget Targets="__SecAnnotate" Condition="'$(Production)' == 'true'" />
</Target>
<Target Name="Clean">
<ItemGroup>
<AllProject Include="$(MSBuildProjectDirectory)\**\*.csproj" />
</ItemGroup>
<RemoveDir Directories="$(BuildDirectory)" ContinueOnError="true" />
<RemoveDir
Directories="%(AllProject.RootDir)%(AllProject.Directory)bin"
Condition="Exists('%(AllProject.RootDir)%(AllProject.Directory)bin')" />
<RemoveDir
Directories="%(AllProject.RootDir)%(AllProject.Directory)obj"
Condition="Exists('%(AllProject.RootDir)%(AllProject.Directory)obj')" />
</Target>
<Target Name="CleanNuGet">
<Message Text="Removing NuGet packages for clean package retrieval." />
<RemoveDir Directories="$(PackageInstallDirectory)" ContinueOnError="false" />
</Target>
<Target Name="Compile">
<!--
Manually restore solution-level packages before build. NuGet doesn't do this automatically
"by design": http://nuget.codeplex.com/workitem/1880
-->
<Exec Command=""$(NuGetCommandLinePath)" restore "%(SolutionFile.FullPath)"" />
<MSBuild Projects="%(SolutionFile.FullPath)" Targets="Build" Properties="Configuration=$(BuildConfiguration)" />
<PropertyGroup>
<CoreSourceDir>$(MSBuildProjectDirectory)\Core\Source</CoreSourceDir>
<ExtrasSourceDir>$(MSBuildProjectDirectory)\Extras\Source</ExtrasSourceDir>
</PropertyGroup>
<ItemGroup>
<BuildArtifactExcludeList Include="$(MSBuildProjectDirectory)\**\*.vshost.*;$(MSBuildProjectDirectory)\**\*.CodeAnalysisLog.*;$(MSBuildProjectDirectory)\**\*.lastcodeanalysissucceeded" />
<Source45Project
Include="
$(CoreSourceDir)\Autofac.Integration.Mvc\**\*.csproj;
$(CoreSourceDir)\Autofac.Integration.Mvc.Owin\**\*.csproj;
$(CoreSourceDir)\Autofac.Integration.Owin\**\*.csproj;
$(CoreSourceDir)\Autofac.Integration.SignalR\**\*.csproj;
$(CoreSourceDir)\Autofac.Integration.WebApi\**\*.csproj;
$(CoreSourceDir)\Autofac.Integration.WebApi.Owin\**\*.csproj" />
<Source40Project
Include="
$(CoreSourceDir)\**\*.csproj;
$(ExtrasSourceDir)\**\*.csproj;"
Exclude="@(Source45Project)" />
<PortableProject
Include="
$(CoreSourceDir)\Autofac\**\*.csproj;
$(ExtrasSourceDir)\Autofac.Extras.CommonServiceLocator\**\*.csproj;
$(ExtrasSourceDir)\Autofac.Extras.MvvmCross\**\*.csproj" />
<Source45OutputList
Include="%(Source45Project.RootDir)%(Source45Project.Directory)bin\$(BuildConfiguration)\%(Source45Project.Filename).*"
Exclude="@(BuildArtifactExcludeList)" />
<Source40OutputList
Include="%(Source40Project.RootDir)%(Source40Project.Directory)bin\$(BuildConfiguration)\%(Source40Project.Filename).*"
Exclude="@(BuildArtifactExcludeList)" />
<PortableOutputList
Include="%(PortableProject.RootDir)%(PortableProject.Directory)bin\$(BuildConfiguration)\%(PortableProject.Filename).*"
Exclude="@(BuildArtifactExcludeList)" />
</ItemGroup>
<Copy SourceFiles="@(Source40OutputList)" DestinationFolder="$(BuildDirectory)\bin\net40" />
<Copy SourceFiles="@(Source45OutputList)" DestinationFolder="$(BuildDirectory)\bin\net45" />
<!--
Portable class library profile string from http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY/preview
based on the profile used in Autofac PCLs.
-->
<Copy SourceFiles="@(PortableOutputList)" DestinationFolder="$(BuildDirectory)\bin\portable-net4+sl5+netcore45+wpa81+wp8+MonoAndroid1+MonoTouch1" />
</Target>
<Target Name="Document">
<!--
Sandcastle Help File Builder 1.9.5.0 requires the DXROOT environment variable
even if you manually provide a path to Sandcastle so we manually execute the
doc task in a small "wrapper" script after setting the environment variable.
-->
<PropertyGroup>
<DocExec><![CDATA[
set DXROOT=$(MSBuildProjectDirectory)\lib\Sandcastle
MSBuild $(MSBuildProjectDirectory)\Build\Documentation.proj /p:DocumentationVersion="$(DocumentationVersion)" /p:BuildDirectory="$(BuildDirectory)"
]]></DocExec>
</PropertyGroup>
<Exec Command="$(DocExec)" WorkingDirectory="$(MSBuildProjectDirectory)\Build" />
</Target>
<Target Name="Package">
<PropertyGroup>
<!-- All packages will end up in the package directory. -->
<PackageDirectory>$(BuildDirectory)\package</PackageDirectory>
<!-- Nuspec/NuGet package contents will be staged in a temporary location for building. -->
<StagingDirectory>$(PackageDirectory)\nuspec-staging</StagingDirectory>
</PropertyGroup>
<ItemGroup>
<!-- Nuspec/NuGet packages get staged using these scripts. -->
<NuspecStagingScripts Include="$(MSBuildProjectDirectory)\**\NuspecStaging.proj" />
</ItemGroup>
<!--
NuGet packaging is done by convention.
In the folder containing the .nuspec file, add a NuspecStaging.proj file. That project should take in
two variables:
* StagingDirectory = the location where all NuGet package contents are being staged.
* BuildBinDirectory = the location where the compiled binaries are.
The NuspecStaging.proj script should:
* Create a folder under the StagingDirectory where it will stage its package structure.
* Copy the .nuspec file into the folder.
* Create the lib/XYZ folder structure using compiled binaries from BuildBinDirectory.
* Copy any additional files required.
* Create a zip package from the appropriate lib folder.
After all Nuspec staging is done, this script will find all .nuspec files in the staging area and:
* Replace any instances of $AFversion_PackageName$ with the corresponding Autofac package version value.
Note we only do this for the main package version, not internal Autofac-to-Autofac dependencies.
* Replace any instances of $version_DependencyName$ with the version found referenced in the
"packages" folder. (eg: $version_Castle.Core$ -> 3.0.0.4001)
* Run nuget pack to create the .nupkg file.
* Move the .nupkg file to the package folder.
* Remove the temporary staging area.
-->
<Message Text="Staging NuGet package contents..." />
<MSBuild Projects="%(NuspecStagingScripts.FullPath)" Properties="BuildBinDirectory=$(BuildDirectory)\bin;StagingDirectory=$(StagingDirectory)" />
<ItemGroup>
<NuspecFiles Include="$(StagingDirectory)\**\*.nuspec" />
</ItemGroup>
<!--Move the zip file out before NuGet packaging. -->
<Message Text="Packaging downloadable zip files..." />
<ItemGroup>
<ZipFiles Include="$(StagingDirectory)\**\*.zip" />
</ItemGroup>
<Move SourceFiles="@(ZipFiles)" DestinationFolder="$(PackageDirectory)" />
<Message Text="Updating NuGet package version info..." />
<FileUpdate Condition="'$(MyGetBuild)' == 'true'" Files="@(NuspecFiles)" Regex="\$AFversion_%(AutofacProject.PackageName)\$" ReplacementText="$([System.String]::Format('%(AutofacProject.PackageVersion)-CI-{0:000}', $([MSBuild]::Add($(BuildCounter), 0))))" />
<FileUpdate Condition="'$(MyGetBuild)' == 'false'" Files="@(NuspecFiles)" Regex="\$AFversion_%(AutofacProject.PackageName)\$" ReplacementText="%(AutofacProject.PackageVersion)" />
<Message Text="Updating NuGet package dependency version info..." />
<GetNuGetDependencyVersions PackageInstallDirectory="$(PackageInstallDirectory)">
<Output TaskParameter="Dependencies" ItemName="LocatedDependencies" />
</GetNuGetDependencyVersions>
<FileUpdate Files="@(NuspecFiles)" Regex="\$version_%(LocatedDependencies.Identity)\$" ReplacementText="%(LocatedDependencies.Version)" />
<Message Text="Packaging NuGet packages..." />
<Exec
Command=""$(NuGetCommandLinePath)" pack %(NuspecFiles.Filename)%(NuspecFiles.Extension) -symbols"
WorkingDirectory="%(NuspecFiles.RootDir)%(NuspecFiles.Directory)" />
<ItemGroup>
<NupkgFiles Include="$(StagingDirectory)\**\*.nupkg" />
</ItemGroup>
<Move SourceFiles="@(NupkgFiles)" DestinationFolder="$(PackageDirectory)" />
<Message Text="Cleaning NuGet staging..." />
<RemoveDir Directories="$(StagingDirectory)" Condition="'$(DeleteNuGetStaging)' == 'true'" />
<Message Text="Packaging complete." />
</Target>
<Target Name="Test">
<ItemGroup>
<TestProject Include="$(MSBuildProjectDirectory)\**\Tests\**\*.csproj" />
<TestAssemblies Include="%(TestProject.RootDir)%(TestProject.Directory)\bin\$(BuildConfiguration)\Autofac*.Tests*.dll" />
<NUnitConsole Include="$(PackageInstallDirectory)\NUnit.Runners.*\tools\nunit-console.exe" />
</ItemGroup>
<PropertyGroup>
<TestResultsFile>$(BuildDirectory)\log\TestResults.xml</TestResultsFile>
<NUnitCommandLineArgs>@(TestAssemblies->'"%(FullPath)"', ' ') /xml:"$(TestResultsFile)" /framework:net-4.0</NUnitCommandLineArgs>
</PropertyGroup>
<MakeDir Directories="$(BuildDirectory)\log" Condition="!Exists('$(BuildDirectory)\log')" />
<Exec Command=""%(NUnitConsole.FullPath)" $(NUnitCommandLineArgs)" />
</Target>
<Target Name="UpdateVersion">
<AssemblyInfo Condition="'%(AutofacProject.PackageName)' != ''"
OutputFile="%(AutofacProject.RootDir)%(AutofacProject.Directory)Properties\VersionAssemblyInfo.cs"
CodeLanguage="CS"
AssemblyVersion="%(AutofacProject.AssemblyVersion)"
AssemblyFileVersion="%(AutofacProject.FileVersion)"
AssemblyConfiguration="$(BuildConfiguration) built on $(BuildTime)"
AssemblyCopyright="Copyright © $(BuildYear) Autofac Contributors"
AssemblyDescription="%(AutofacProject.PackageName) %(AutofacProject.PackageVersion)" />
<AssemblyInfo Condition="'%(AutofacProject.PackageName)' == ''"
OutputFile="%(AutofacProject.RootDir)%(AutofacProject.Directory)Properties\VersionAssemblyInfo.cs"
CodeLanguage="CS"
AssemblyVersion="%(AutofacProject.AssemblyVersion)"
AssemblyFileVersion="%(AutofacProject.FileVersion)"
AssemblyConfiguration="$(BuildConfiguration) built on $(BuildTime)"
AssemblyCopyright="Copyright © $(BuildYear) Autofac Contributors" />
</Target>
<Target Name="__EnvironmentSetup">
<Time Format="yyyy-MM-dd HH:mm">
<Output TaskParameter="FormattedTime" PropertyName="BuildTime" />
</Time>
<Time Format="yyyy">
<Output TaskParameter="FormattedTime" PropertyName="BuildYear" />
</Time>
<Message Text="Environment Setup:" />
<Message Text="Assembly Version: $(AssemblyVersion)" />
<Message Text="Build Configuration: $(BuildConfiguration)" />
<Message Text="Build Directory: $(BuildDirectory)" />
<Message Text="Build Time: $(BuildTime)" />
</Target>
<Target Name="__SecAnnotate">
<!--
Dependency detection and working directory is different between .NET 4.0 and 4.5 so
there's some complexity here to split the analysis up.
-->
<PropertyGroup>
<!-- Too many parameters for the comand line, so parameters get written to response files. -->
<SecAnnotateAnalyzeResponseFile40>$(BuildDirectory)\log\SecAnnotateAnalyzeList40.txt</SecAnnotateAnalyzeResponseFile40>
<SecAnnotateReferenceResponseFile40>$(BuildDirectory)\log\SecAnnotateReferenceList40.txt</SecAnnotateReferenceResponseFile40>
<SecAnnotateAnalyzeResponseFile45>$(BuildDirectory)\log\SecAnnotateAnalyzeList45.txt</SecAnnotateAnalyzeResponseFile45>
<SecAnnotateReferenceResponseFile45>$(BuildDirectory)\log\SecAnnotateReferenceList45.txt</SecAnnotateReferenceResponseFile45>
</PropertyGroup>
<ItemGroup>
<!--
Only analyze the .NET 4.0/4.5 assemblies. This shouldn't change if multi-targeting because
Silverlight, Windows Phone, etc. don't have the same security model as .NET 4.0.
-->
<SecAnnotateAnalyzeAssemblies40 Include="$(BuildDirectory)\bin\net40\*.dll" />
<SecAnnotateAnalyzeAssemblies45 Include="$(BuildDirectory)\bin\net45\*.dll" />
<!--
We need to dynamically determine which assemblies/versions are being used so SecAnnotate can do
its job. Without correct references, SecAnnotate fails or analyzes incorrectly.
The first block here finds - in groups - the set of dependencies from NuGet that are...
* .NET 4.5
* .NET 4.0
* .NET 4.0 Client Profile
* .NET 3.5
-->
<DetectedDependencies45 Include="$(BuildDirectory)\bin\net40\*.dll;$(PackageInstallDirectory)\**\*net45*\*.dll;$(PackageInstallDirectory)\**\45\*.dll;$(PackageInstallDirectory)\**\*portable*\*.dll" />
<DetectedDependencies40 Include="$(PackageInstallDirectory)\**\*net40*\*.dll;$(PackageInstallDirectory)\**\40\*.dll;$(PackageInstallDirectory)\**\*portable*\*.dll" />
<DetectedDependencies40Client Include="$(PackageInstallDirectory)\**\*net40-client*\*.dll;$(PackageInstallDirectory)\**\40-client\*.dll;$(PackageInstallDirectory)\**\*portable*\*.dll" />
<DetectedDependencies35 Include="$(PackageInstallDirectory)\**\net35\*.dll;$(PackageInstallDirectory)\**\35\*.dll" />
<!--
This block of items aggregates the set of grouped dependencies from above. We need UNIQUE
dependencies by name (e.g., you can't include two "Castle.Core" references) so we fall
back, first opting for the .NET 4.5, then 4.0, then 4.0 client profile, then 3.5 assemblies.
In the end, DetectedDependencies will be a list of names ("Castle.Core"), each with a metadata
item "HintPath" that points to the full path of the detected assembly.
-->
<ResolvedDependencies45 Include="%(DetectedDependencies45.Filename)">
<HintPath>%(DetectedDependencies45.FullPath)</HintPath>
</ResolvedDependencies45>
<ResolvedDependencies45 Include="%(DetectedDependencies40.Filename)" Exclude="@(ResolvedDependencies45)">
<HintPath>%(DetectedDependencies40.FullPath)</HintPath>
</ResolvedDependencies45>
<ResolvedDependencies45 Include="%(DetectedDependencies40Client.Filename)" Exclude="@(ResolvedDependencies45)">
<HintPath>%(DetectedDependencies40Client.FullPath)</HintPath>
</ResolvedDependencies45>
<ResolvedDependencies45 Include="%(DetectedDependencies35.Filename)" Exclude="@(ResolvedDependencies45)">
<HintPath>%(DetectedDependencies35.FullPath)</HintPath>
</ResolvedDependencies45>
<ResolvedDependencies40 Include="%(DetectedDependencies40.Filename)">
<HintPath>%(DetectedDependencies40.FullPath)</HintPath>
</ResolvedDependencies40>
<ResolvedDependencies40 Include="%(DetectedDependencies40Client.Filename)" Exclude="@(DetectedDependencies)">
<HintPath>%(DetectedDependencies40Client.FullPath)</HintPath>
</ResolvedDependencies40>
<ResolvedDependencies40 Include="%(DetectedDependencies35.Filename)" Exclude="@(DetectedDependencies)">
<HintPath>%(DetectedDependencies35.FullPath)</HintPath>
</ResolvedDependencies40>
<!--
Finally, switch the list of detected dependencies to actually point to the
files so we can find the directories. We'll tell SecAnnotate the list of
directories so it can search for dependencies, appropriately using only
the set of directories we're ostensibly using ourselves based on the detected
set of assemblies above.
In the end we'll have lists of folders like
...\packages\Castle.Core.3.0.0.4001\lib\net40
...\packages\CommonServiceLocator.1.0\lib\net35
But only the ones that point to the actual target frameworks we're using.
-->
<SecAnnotateReferenceAssemblies40 Include="%(ResolvedDependencies40.HintPath);$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\*.dll" />
<SecAnnotateReferenceDirectories40 Include="%(SecAnnotateReferenceAssemblies40.RootDir)%(SecAnnotateReferenceAssemblies40.Directory)" />
<SecAnnotateReferenceAssemblies45 Include="%(ResolvedDependencies45.HintPath);$(ProgramFiles)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\*.dll" />
<SecAnnotateReferenceDirectories45 Include="%(SecAnnotateReferenceAssemblies45.RootDir)%(SecAnnotateReferenceAssemblies45.Directory)" />
</ItemGroup>
<!-- Files get written using batching so we always append. Delete existing ones first to start clean. -->
<Delete Files="$(SecAnnotateAnalyzeResponseFile40)" Condition="Exists('$(SecAnnotateAnalyzeResponseFile40)')" />
<Delete Files="$(SecAnnotateReferenceResponseFile40)" Condition="Exists('$(SecAnnotateReferenceResponseFile40)')" />
<Delete Files="$(SecAnnotateAnalyzeResponseFile45)" Condition="Exists('$(SecAnnotateAnalyzeResponseFile45)')" />
<Delete Files="$(SecAnnotateReferenceResponseFile45)" Condition="Exists('$(SecAnnotateReferenceResponseFile45)')" />
<WriteLinesToFile
File="$(SecAnnotateAnalyzeResponseFile40)"
Lines="%(SecAnnotateAnalyzeAssemblies40.FullPath)"
Overwrite="false" />
<WriteLinesToFile
File="$(SecAnnotateReferenceResponseFile40)"
Lines="/d:%(SecAnnotateReferenceDirectories40.FullPath)"
Overwrite="false" />
<WriteLinesToFile
File="$(SecAnnotateAnalyzeResponseFile45)"
Lines="%(SecAnnotateAnalyzeAssemblies45.FullPath)"
Overwrite="false" />
<WriteLinesToFile
File="$(SecAnnotateReferenceResponseFile45)"
Lines="/d:%(SecAnnotateReferenceDirectories45.FullPath)"
Overwrite="false" />
<!--
SecAnnotate will issue a warning like this because of the PCL library references. There's
nothing we can do, but it's NOT A PROBLEM.
EXEC : warning : Unifying desktop and CoreCLR mscorlib references together. Make sure
that all assemblies being loaded are desktop assemblies, or all assemblies are CoreCLR
assemblies. [C:\autofac\trunk\default.proj]
We're also ignoring the "TransparencyAnnotationsShouldNotConflict" rule because this
conflicts with FxCop recommendations and is only something that has to do with "people
being confused in code reviews." The security should still work right, and it's usually
better to err on the side of FxCop in these cases. You usually actually don't want
to change security in method overrides.
For example, for a method that registers UrlHelper in the container...
* SecAnnotate: "This is a security critical method so must be marked SecurityCritical or SecuritySafeCritical"
* FxCop: "This is an override of a transparent method so don't mark it SecurityCritical or SecuritySafeCritical"
-->
<Exec
Command="SecAnnotate.exe /q /s:TransparencyAnnotationsShouldNotConflict /o:"$(BuildDirectory)\log\SecAnnotateResults40.xml" @"$(SecAnnotateReferenceResponseFile40)" @"$(SecAnnotateAnalyzeResponseFile40)""
WorkingDirectory="$(BuildDirectory)\bin\net40\" />
<Exec
Command="SecAnnotate.exe /q /s:TransparencyAnnotationsShouldNotConflict /o:"$(BuildDirectory)\log\SecAnnotateResults45.xml" @"$(SecAnnotateReferenceResponseFile45)" @"$(SecAnnotateAnalyzeResponseFile45)""
WorkingDirectory="$(BuildDirectory)\bin\net45\" />
</Target>
<UsingTask TaskName="GetNuGetDependencyVersions" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<PackageInstallDirectory Required="true" />
<Dependencies ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.Collections.Generic" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
// Match package folders like Castle.Core.3.0.0.4001
// Groups[1] = "Castle.Core"
// Groups[2] = "3.0.0.4001"
var re = new Regex(@"^(.+?)\.(([0-9]+)[A-Za-z0-9\.\-]*)$");
try
{
// Create item metadata based on the list of packages found
// in the PackageInstallDirectory. Item identities will be
// the name of the package ("Castle.Core") and they'll have
// a "Version" metadata item with the package version.
var returnItems = new List<ITaskItem>();
var seen = new List<string>();
foreach(var directory in Directory.EnumerateDirectories(PackageInstallDirectory))
{
var directoryName = Path.GetFileName(directory);
var match = re.Match(directoryName);
if(!match.Success)
{
continue;
}
var name = match.Groups[1].Value;
if(name.StartsWith("Autofac"))
{
// Ignore Autofac components because we manually specify
// those versions right in the .nuspec.
continue;
}
if(seen.Contains(name))
{
// If there are duplicate NuGet package names, that's a problem
// because the .nuspecs will potentially get the wrong version
// inserted. Err out so cleanup can happen.
throw new InvalidOperationException(String.Format("Multiple copies of component {0} found in NuGet package folder {1}. Update projects and clean up so only one version of the package exists.", name, PackageInstallDirectory));
}
seen.Add(name);
var version = match.Groups[2].Value;
var metadata = new Dictionary<string, string>();
metadata["Version"] = version;
var item = new TaskItem(name, metadata);
returnItems.Add(item);
}
Dependencies = returnItems.ToArray();
return true;
}
catch(Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>
</Project>