This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathMicrosoft.CodeContracts.targets
666 lines (603 loc) · 27.9 KB
/
Microsoft.CodeContracts.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
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Multiple Import Guard -->
<PropertyGroup>
<CodeContractsImported>True</CodeContractsImported>
</PropertyGroup>
<!--=====================================================================
Begin Microsoft Code Contracts
======================================================================-->
<PropertyGroup>
<CodeContractsDeclDir>$(OutDir)CodeContractsDeclarative\</CodeContractsDeclDir>
<CodeContractsContractSubDir>CodeContracts\</CodeContractsContractSubDir>
<CodeContractsCCRefgenCommand>$(CodeContractsInstallDir)Bin\ccrefgen.exe</CodeContractsCCRefgenCommand>
</PropertyGroup>
<Choose>
<When Condition="'$(TargetFrameworkIdentifier)' == 'Silverlight'">
<Choose>
<When Condition="'$(TargetFrameworkVersion)' == 'v5.0'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\Silverlight\v5.0</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.0'">
<Choose>
<When Condition="'$(TargetFrameworkProfile)' == 'WindowsPhone'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\Silverlight\v4.0\Profile\WindowsPhone</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\Silverlight\v4.0</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</Otherwise>
</Choose>
</When>
<Otherwise>
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\Silverlight\v3.0</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</Otherwise>
</Choose>
</When>
<Otherwise>
<Choose>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.0'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.0</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.5'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.5</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.5.1'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.5</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.5.2'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.5</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.6'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.6</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.6.1'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.6</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<When Condition="'$(TargetFrameworkVersion)' == 'v4.6.2'">
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.6</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\v3.5</CodeContractsReferenceAssemblyLibPath>
</PropertyGroup>
</Otherwise>
</Choose>
</Otherwise>
</Choose>
<!--=====================================================================
Build Contract reference assemblies on all builds.
(rather than recursively on demand)
Also define CONTRACTS_FULL and CODE_ANALYSIS dynamically, otherwise
VS property build pane picks it up and may persist it into the project
settings!
=====================================================================-->
<PropertyGroup>
<CompileDependsOn>CodeContractsSlipInDefineSymbolDynamically;$(CompileDependsOn);CodeContractReferenceAssembly</CompileDependsOn>
</PropertyGroup>
<Target
Name="CodeContractsSlipInDefineSymbolDynamically"
Condition="'$(CodeContractsEnableRuntimeChecking)' == 'true'"
>
<CreateProperty
Condition="'$(Language)'=='C#'"
Value="CONTRACTS_FULL;CODE_ANALYSIS;$(DefineConstants)">
<Output
TaskParameter="Value"
PropertyName="DefineConstants" />
</CreateProperty>
<CreateProperty
Condition="'$(Language)'=='VB'"
Value="CONTRACTS_FULL=-1,CODE_ANALYSIS=-1,$(FinalDefineConstants)">
<Output
TaskParameter="Value"
PropertyName="FinalDefineConstants" />
</CreateProperty>
</Target>
<!--=====================================================================
Determine level of runtime checking
======================================================================-->
<Choose>
<When Condition="'$(CodeContractsRuntimeCheckingLevel)'=='Full'">
<PropertyGroup>
<CodeContractsRuntimeLevel>4</CodeContractsRuntimeLevel>
</PropertyGroup>
</When>
<!-- default -->
<When Condition="'$(CodeContractsRuntimeCheckingLevel)'==''">
<PropertyGroup>
<CodeContractsRuntimeLevel>4</CodeContractsRuntimeLevel>
</PropertyGroup>
</When>
<When Condition="'$(CodeContractsRuntimeCheckingLevel)'=='Pre and Post'">
<PropertyGroup>
<CodeContractsRuntimeLevel>3</CodeContractsRuntimeLevel>
</PropertyGroup>
</When>
<When Condition="'$(CodeContractsRuntimeCheckingLevel)'=='Preconditions'">
<PropertyGroup>
<CodeContractsRuntimeLevel>2</CodeContractsRuntimeLevel>
</PropertyGroup>
</When>
<!-- for backward compatibility -->
<When Condition="'$(CodeContractsRuntimeCheckingLevel)'=='RequiresAlways'">
<PropertyGroup>
<CodeContractsRuntimeLevel>1</CodeContractsRuntimeLevel>
</PropertyGroup>
</When>
<When Condition="'$(CodeContractsRuntimeCheckingLevel)'=='ReleaseRequires'">
<PropertyGroup>
<CodeContractsRuntimeLevel>1</CodeContractsRuntimeLevel>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<CodeContractsRuntimeLevel>0</CodeContractsRuntimeLevel>
</PropertyGroup>
</Otherwise>
</Choose>
<PropertyGroup
Condition="'$(CodeContractsEnableRuntimeChecking)' == 'true'">
<!--=====================================================================
C# and VB specific extra defined constants and rewrite post
build step
Must run prior to other CreateManifests steps in order to properly capture signature in manifest.
Need to run right after the compilation; otherwise other tools (such as the one that creates
a winmd file) will use the pre-rewritten assembly.
======================================================================-->
<CompileDependsOn>$(CompileDependsOn); CodeContractInstrument</CompileDependsOn>
</PropertyGroup>
<!--=====================================================================
Add post build step for contract XML documentation generation
======================================================================-->
<PropertyGroup
Condition="'$(CodeContractsEmitXMLDocs)' == 'true'">
<CompileDependsOn>$(CompileDependsOn);ContractXmlDocumentation</CompileDependsOn>
</PropertyGroup>
<!--=====================================================================
Define tool options
======================================================================-->
<PropertyGroup
Condition="'$(CodeContractsEnableRuntimeChecking)' == 'true'">
<CodeContractRewriteOptions
Condition="'$(TargetFrameworkVersion)' != ''"
>$(CodeContractRewriteOptions) "/framework:$(TargetFrameworkVersion)"</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsPlatformPath)' != ''"
>$(CodeContractRewriteOptions) "/targetplatform:$(CodeContractsPlatformPath)"</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsClassLibrary)' != ''"
>$(CodeContractRewriteOptions) "/contractLibrary:$(CodeContractsClassLibrary)"</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsAssemblyMode)' == '1'"
>$(CodeContractRewriteOptions) "/assemblyMode=standard"</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsRuntimeOnlyPublicSurface)' == 'true'"
>$(CodeContractRewriteOptions) /publicsurface</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsRuntimeThrowOnFailure)' != 'false'"
>$(CodeContractRewriteOptions) /throwonfailure</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsRuntimeCallSiteRequires)' == 'true'"
>$(CodeContractRewriteOptions) /callsiterequires</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsRuntimeSkipQuantifiers)' == 'true'"
>$(CodeContractRewriteOptions) /skipQuantifiers</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsCustomRewriterAssembly)' != '' and '$(CodeContractsCustomRewriterClass)' != ''"
>$(CodeContractRewriteOptions) "/rewriterMethods:$(CodeContractsCustomRewriterAssembly),$(CodeContractsCustomRewriterClass)"</CodeContractRewriteOptions>
<CodeContractRewriteOptions
Condition="'$(CodeContractsExtraRewriteOptions)' != ''"
>$(CodeContractRewriteOptions) $(CodeContractsExtraRewriteOptions)</CodeContractRewriteOptions>
<CodeContractRewriteOptions>/level:$(CodeContractsRuntimeLevel) /nologo /rewrite $(CodeContractRewriteOptions) "/resolvedPaths:@(ReferencePath,';')" "/libpaths:@(CodeContractsAllLibPaths) " "$(TargetName)$(TargetExt)"</CodeContractRewriteOptions>
<CodeContractRewriteCommand>$(CodeContractsInstallDir)Bin\ccrewrite.exe</CodeContractRewriteCommand>
<CodeContractsRewriterOutput>$(IntermediateOutputPath)$(TargetName).rewritten</CodeContractsRewriterOutput>
</PropertyGroup>
<ItemGroup
Condition="'$(CodeContractsEnableRuntimeChecking)' == 'true'">
<CodeContractsRewriterInputs
Include="@(ReferencePath)"/>
<CodeContractsRewriterInputs
Include="@(IntermediateAssembly)"/>
<CodeContractsRewriterInputs
Include="$(IntermediateOutputPath)$(TargetName).pdb"/>
</ItemGroup>
<!--=====================================================================
Runtime check instrumentation
======================================================================-->
<Target
Name="CodeContractRewrite"
Condition="'$(CodeContractsEnableRuntimeChecking)' == 'true'"
DependsOnTargets="CodeContractsComputeAllLibPaths;EnsureContractReferenceAssemblyOfDependeeProjects;$(CodeContractRewriteDependsOn)"
Inputs="@(CodeContractsRewriterInputs)"
Outputs="$(CodeContractsRewriterOutput)"
>
<PropertyGroup>
<_CodeContractsCCRewriteArguments>$(CodeContractRewriteOptions)</_CodeContractsCCRewriteArguments>
</PropertyGroup>
<ItemGroup>
<_CodeContractsCCRewriteArgumentLines
Include="$(_CodeContractsCCRewriteArguments)"
/>
</ItemGroup>
<WriteLinesToFile
File="$(IntermediateOutputPath)$(AssemblyName).ccrewrite.rsp"
Lines="@(_CodeContractsCCRewriteArgumentLines, ';')"
Overwrite="true"
/>
<Exec
WorkingDirectory="$(IntermediateOutputPath)"
Command='"$(CodeContractRewriteCommand)" "@$(AssemblyName).ccrewrite.rsp"'
/>
<CallTarget Targets="CodeContractReSign"/>
<WriteLinesToFile
File="$(CodeContractsRewriterOutput)"
/>
<Touch Files="$(CodeContractsRewriterOutput)"/>
<ItemGroup>
<FileWrites
Include="$(CodeContractsRewriterOutput)"/>
</ItemGroup>
</Target>
<Target
Name="CodeContractReSign"
Condition="'$(DelaySign)' != 'true'"
>
<GetFrameworkSdkPath>
<Output
TaskParameter="Path"
PropertyName="CodeContractsSdkPath" />
</GetFrameworkSdkPath>
<PropertyGroup>
<!-- SN is in the Framework SDK tools path, but TargetFrameworkSDKToolsDirectory isn't always available -->
<CodeContractsSnExe Condition=" '$(TargetFrameworkSDKToolsDirectory)' != '' ">$(TargetFrameworkSDKToolsDirectory)sn.exe</CodeContractsSnExe>
<CodeContractsSnExe Condition=" '$(TargetFrameworkSDKToolsDirectory)' == '' ">$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\sn.exe</CodeContractsSnExe>
</PropertyGroup>
<Exec
Condition="'$(KeyOriginatorFile)' != ''"
Command='"$(CodeContractsSnExe)" /R "@(IntermediateAssembly)" "$(KeyOriginatorFile)"' />
<Exec
Condition="'$(KeyContainerName)' != ''"
Command='"$(CodeContractsSnExe)" /Rc "@(IntermediateAssembly)" "$(KeyContainerName)"' />
</Target>
<Target
Name="CodeContractInstrument"
Condition="'$(CodeContractsEnableRuntimeChecking)' == 'true' and '$(BuildingProject)'=='true'"
DependsOnTargets="CodeContractRewrite"
>
</Target>
<!--=====================================================================
Building Contract Reference Assemblies
======================================================================-->
<ItemGroup>
<_CodeContractOutputDirectory Include="$(OutDir)$(CodeContractsContractSubDir)"/>
<_ContractDummyReferenceAssembly Include="$(OutDir)$(CodeContractsContractSubDir)$(TargetName).noReferenceAssembly"/>
<ContractReferenceAssembly Include="$(OutDir)$(CodeContractsContractSubDir)$(TargetName).Contracts.dll"/>
<ContractReferenceAssemblyAbsolute Include="@(ContractReferenceAssembly->'%(FullPath)')"/>
<ContractReferenceAssemblyPDB Include="$(OutDir)$(CodeContractsContractSubDir)$(TargetName).Contracts.pdb"/>
<ContractDeclarativeAssembly Include="$(CodeContractsDeclDir)$(TargetName)$(TargetExt)"/>
<ContractDeclarativeAssemblyPDB Include="$(CodeContractsDeclDir)$(TargetName).pdb"/>
<ContractReferenceAssemblies Include="@(ContractReferenceAssembly);@(ContractReferenceAssemblyPDB)"/>
<ContractDeclarativeAssemblies Include="@(ContractDeclarativeAssembly);@(ContractDeclarativeAssemblyPDB)"/>
<CodeContractOutputDirectory Include="@(_CodeContractOutputDirectory->'%(RootDir)%(Directory)')"/>
<ContractDummyReferenceAssembly Include="@(_ContractDummyReferenceAssembly->'%(FullPath)')"/>
</ItemGroup>
<Target
Condition="'$(BuildingProject)'=='true'"
Name="CodeContractReferenceAssembly"
DependsOnTargets="CreateCodeContractReferenceAssembly;CodeContractDummyReferenceAssembly"
/>
<Target
Name="CreateCodeContractReferenceAssembly"
Condition="'$(TargetName)' != 'Microsoft.Contracts' and '$(CodeContractsReferenceAssembly)' == 'build'"
DependsOnTargets="ContractDeclarativeAssembly;$(CodeContractReferenceAssemblyDependsOn);MakeCodeContractOutputDirectory;CodeContractsComputeAllLibPaths"
Inputs="@(ContractDeclarativeAssemblies)"
Outputs="@(ContractReferenceAssemblyAbsolute)">
<PropertyGroup>
<_CodeContractsCCRefGenArguments>"/resolvedPaths:@(ReferencePath,';')" "/libPaths:@(CodeContractsAllLibPaths) " /pdb "/out:@(ContractReferenceAssembly)" "@(ContractDeclarativeAssembly)"</_CodeContractsCCRefGenArguments>
</PropertyGroup>
<ItemGroup>
<_CodeContractsCCRefGenArgumentLines
Include="$(_CodeContractsCCRefGenArguments)"
/>
</ItemGroup>
<WriteLinesToFile
File="$(IntermediateOutputPath)$(AssemblyName).ccrefgen.rsp"
Lines="@(_CodeContractsCCRefGenArgumentLines, ';')"
Overwrite="true"
/>
<Exec
Condition="Exists('@(ContractDeclarativeAssembly)')"
Command='"$(CodeContractsCCRefgenCommand)" "@$(IntermediateOutputPath)$(AssemblyName).ccrefgen.rsp"'
/>
<ItemGroup
Condition="Exists('@(ContractReferenceAssemblyAbsolute)')">
<FileWrites
Include="@(ContractReferenceAssemblies);$(IntermediateOutputPath)$(AssemblyName).ccrefgen.rsp"/>
</ItemGroup>
</Target>
<Target
Name="CodeContractDummyReferenceAssembly"
Condition="'$(CodeContractsReferenceAssembly)' == 'doNotBuild'"
DependsOnTargets="MakeCodeContractOutputDirectory"
Outputs="@(ContractDummyReferenceAssembly)">
<Touch
Condition="!Exists(@(ContractDummyReferenceAssembly))"
AlwaysCreate="true"
Files="@(ContractDummyReferenceAssembly)"
/>
<ItemGroup>
<FileWrites
Include="@(ContractDummyReferenceAssembly)"/>
</ItemGroup>
</Target>
<Target
Name="MakeCodeContractOutputDirectory"
Condition="!Exists(@(CodeContractOutputDirectory))"
>
<Message
Text="Making directory @(CodeContractOutputDirectory)"
/>
<MakeDir
Directories="@(CodeContractOutputDirectory)"/>
</Target>
<Target
Name="EnsureContractReferenceAssemblyOfDependeeProjects"
Condition="'@(_ResolvedProjectReferencePaths)' != ''"
>
<Message
Text="EnsureContractReferenceAssemblies: @(_ResolvedProjectReferencePaths)"
Importance="low"
/>
<!--
Issue the warning *only* for C# and VB projects because those are the only ones that the user
can shut off the warning by changing the settings.
-->
<Warning
Condition="!Exists('%(RootDir)%(Directory)CodeContracts\%(Filename).Contracts.dll') and !Exists('%(RootDir)%(Directory)\CodeContracts\%(Filename).noReferenceAssembly') and ('$([System.IO.Path]::GetExtension(%(_ResolvedProjectReferencePaths.OriginalItemSpec)))' == '.csproj' or '$([System.IO.Path]::GetExtension(%(_ResolvedProjectReferencePaths.OriginalItemSpec)))' == '.vbproj')"
Text="Contract reference assembly for project '%(Filename)' not found. Select 'Build' or 'DoNotBuild' for Contract Reference in project settings."
HelpKeyword="@(_ResolvedProjectReferencePaths)"
/>
</Target>
<!--=====================================================================
Building Contract Declarative Assemblies
======================================================================-->
<Target
Name="ContractDeclarativeAssembly"
DependsOnTargets="ContractsMakeDeclDir;ResolveReferences;ResolveKeySource;ContractDeclarativeAssemblyCS;ContractDeclarativeAssemblyVB"
/>
<Target Name="ContractsMakeDeclDir">
<MakeDir
Condition="!Exists('$(CodeContractsDeclDir)')"
Directories="$(CodeContractsDeclDir)"/>
</Target>
<Target
Name="ContractDeclarativeAssemblyVB"
Condition="'$(Language)'=='VB'"
DependsOnTargets=""
Inputs="$(MSBuildAllProjects);
@(Compile)"
Outputs="@(ContractDeclarativeAssembly->'%(FullPath)')"
>
<ItemGroup>
<ContractDeclarativeSources Include="@(Compile);$(CodeContractsInstallDir)Languages\VisualBasic\ContractDeclarativeAssemblyAttribute.vb"/>
</ItemGroup>
<Message Text="Build Declarative Contract Assembly for VB $(TargetPath)"/>
<Vbc Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
AdditionalLibPaths="$(AdditionalLibPaths)"
AddModules="@(AddModules)"
BaseAddress="$(BaseAddress)"
CodePage="$(CodePage)"
DebugType="$(DebugType)"
DefineConstants="$(FinalDefineConstants),CONTRACTS_FULL=-1,CODE_ANALYSIS=-1"
DelaySign="$(DelaySign)"
DisabledWarnings="$(NoWarn)"
DocumentationFile=""
EmitDebugInformation="$(DebugSymbols)"
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
GenerateDocumentation=""
Imports="@(Import)"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
LangVersion="$(LangVersion)"
MainEntryPoint="$(StartupObject)"
ModuleAssemblyName="$(ModuleAssemblyName)"
NoConfig="true"
NoStandardLib="$(NoCompilerStandardLib)"
NoVBRuntimeReference="$(NoVBRuntimeReference)"
NoWarnings="$(_NoWarnings)"
NoWin32Manifest="$(NoWin32Manifest)"
Optimize="true"
OptionCompare="$(OptionCompare)"
OptionExplicit="$(OptionExplicit)"
OptionInfer="$(OptionInfer)"
OptionStrict="$(OptionStrict)"
OptionStrictType="$(OptionStrictType)"
OutputAssembly="@(ContractDeclarativeAssembly)"
Platform="$(PlatformTarget)"
References="@(ReferencePath)"
RemoveIntegerChecks="$(RemoveIntegerChecks)"
Resources="@(_CoreCompileResourceInputs);@(CompiledLicenseFile)"
ResponseFiles="$(CompilerResponseFile)"
RootNamespace="$(RootNamespace)"
SdkPath="$(FrameworkPathOverride)"
Sources="@(ContractDeclarativeSources)"
TargetCompactFramework="$(TargetCompactFramework)"
TargetType="$(OutputType)"
ToolExe="$(VbcToolExe)"
ToolPath="$(VbcToolPath)"
TreatWarningsAsErrors="false"
UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
Utf8Output="$(Utf8Output)"
Verbosity="$(VbcVerbosity)"
WarningsAsErrors=""
WarningsNotAsErrors="$(WarningsNotAsErrors)"
Win32Icon="$(ApplicationIcon)"
Win32Manifest="$(Win32Manifest)"
Win32Resource="$(Win32Resource)"
/>
<ItemGroup>
<FileWrites
Include="@(ContractDeclarativeAssemblies)"/>
</ItemGroup>
</Target>
<Target
Name="ContractDeclarativeAssemblyCS"
Condition="'$(Language)'=='C#'"
DependsOnTargets=""
Inputs="$(MSBuildAllProjects);
@(Compile)"
Outputs="@(ContractDeclarativeAssembly->'%(FullPath)')"
>
<ItemGroup>
<ContractDeclarativeSources Include="@(Compile);$(CodeContractsInstallDir)Languages\CSharp\ContractDeclarativeAssemblyAttribute.cs"/>
</ItemGroup>
<Message Text="Build Declarative Contract Assembly for C# $(TargetPath)"/>
<Csc
AdditionalLibPaths="$(AdditionalLibPaths)"
AddModules="@(AddModules)"
AllowUnsafeBlocks="$(AllowUnsafeBlocks)"
BaseAddress="$(BaseAddress)"
CheckForOverflowUnderflow="$(CheckForOverflowUnderflow)"
CodePage="$(CodePage)"
DebugType="full"
DefineConstants="$(DefineConstants);CONTRACTS_FULL;CODE_ANALYSIS"
DelaySign="$(DelaySign)"
DisabledWarnings="$(NoWarn)"
DocumentationFile=""
EmitDebugInformation="true"
ErrorReport="$(ErrorReport)"
FileAlignment="$(FileAlignment)"
GenerateFullPaths="$(GenerateFullPaths)"
KeyContainer="$(KeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
LangVersion="$(LangVersion)"
MainEntryPoint="$(StartupObject)"
ModuleAssemblyName="$(ModuleAssemblyName)"
NoConfig="true"
NoLogo="$(NoLogo)"
NoStandardLib="$(NoCompilerStandardLib)"
NoWin32Manifest="$(NoWin32Manifest)"
Optimize="true"
OutputAssembly="@(ContractDeclarativeAssembly)"
PdbFile="@(ContractDeclarativeAssemblyPDB)"
Platform="$(PlatformTarget)"
References="@(ReferencePath)"
Resources=""
ResponseFiles="$(CompilerResponseFile)"
Sources="@(ContractDeclarativeSources)"
TargetType="$(OutputType)"
ToolExe="$(CscToolExe)"
ToolPath="$(CscToolPath)"
TreatWarningsAsErrors="false"
UseHostCompilerIfAvailable="$(UseHostCompilerIfAvailable)"
Utf8Output="$(Utf8Output)"
WarningLevel="0"
WarningsAsErrors=""
WarningsNotAsErrors="$(WarningsNotAsErrors)"
Win32Icon=""
Win32Manifest="$(Win32Manifest)"
Win32Resource="$(Win32Resource)"
/>
<ItemGroup>
<FileWrites
Include="@(ContractDeclarativeAssemblies)"/>
</ItemGroup>
</Target>
<Target
Name="CodeContractsComputeReferencedLibPaths">
<ItemGroup>
<_CodeContractsBuildReferences
Include="@(ReferencePath->'%(RootDir)%(Directory)')"/>
<_CodeContractsBuildReferences
Include="@(ReferencePath->'%(RootDir)%(Directory)CodeContracts')"/>
</ItemGroup>
<RemoveDuplicates
Inputs="@(_CodeContractsBuildReferences)">
<Output
TaskParameter="Filtered"
ItemName="CodeContractsBuildLibPaths"/>
</RemoveDuplicates>
</Target>
<Target
Name="CodeContractsComputeAllLibPaths"
DependsOnTargets="CodeContractsComputeReferencedLibPaths"
>
<Message Text="CodeContractsComputeAllLibPaths" Importance="low"/>
<RemoveDuplicates
Inputs="@(CodeContractsBuildLibPaths);$(CodeContractsReferenceAssemblyLibPath);$(CodeContractsLibPaths)">
<Output
TaskParameter="Filtered"
ItemName="CodeContractsAllLibPaths"/>
</RemoveDuplicates>
</Target>
<!--=====================================================================
Building XML Documentation for Contracts
======================================================================-->
<Target
Name="CompensateForVBSettingOfDocFileItem">
<!--
** VB sets DocFileItem to the obj/x86/Debug (or whatever configuration) directory for some reason.
** Updating the value of that variable has to be done in a task prior to the ContractXmlDocumentation target.
-->
<ItemGroup Condition="'$(Language)' == 'VB'"> <!-- see this defined at the top of m.visualbasic.targets -->
<DocFileItem Remove="@(DocFileItem)"/> <!-- empty out existing value -->
<DocFileItem Include="$(OutputPath)$(DocumentationFile)" Condition="'$(DocumentationFile)'!=''"/> <!-- use path into final bin dir instead -->
</ItemGroup>
</Target>
<PropertyGroup>
<CodeContractsCCDocgenCommand>$(CodeContractsInstallDir)Bin\ccdocgen.exe</CodeContractsCCDocgenCommand>
</PropertyGroup>
<Target
Name="ContractXmlDocumentation"
Condition="Exists('@(DocFileItem)') and Exists('@(ContractReferenceAssemblyAbsolute)') and '$(BuildingProject)'=='true'"
DependsOnTargets="CodeContractReferenceAssembly;CodeContractsComputeAllLibPaths;CompensateForVBSettingOfDocFileItem"
Inputs="@(ContractReferenceAssembly);@(DocFileItem)"
Outputs="@(DocFileItem)">
<PropertyGroup>
<_CodeContractsCCDocGenArguments>-assembly "@(ContractReferenceAssembly)" -xmlFile "@(DocFileItem)" "-resolvedPaths:@(ReferencePath)" -libpaths "@(CodeContractsAllLibPaths) "</_CodeContractsCCDocGenArguments>
</PropertyGroup>
<ItemGroup>
<_CodeContractsCCDocGenArgumentLines
Include="$(_CodeContractsCCDocGenArguments)"
/>
</ItemGroup>
<WriteLinesToFile
File="$(IntermediateOutputPath)$(AssemblyName).ccdocgen.rsp"
Lines="@(_CodeContractsCCDocGenArgumentLines, ';')"
Overwrite="true"
/>
<Exec
Command='"$(CodeContractsCCdocgenCommand)" "@$(IntermediateOutputPath)$(AssemblyName).ccdocgen.rsp"'
/>
</Target>
<!--=====================================================================
Include Code Analysis target if present
======================================================================-->
<PropertyGroup>
<CodeContractAnalysisTargets>$(CodeContractsInstallDir)MsBuild\v14.0\Microsoft.CodeContractAnalysis.targets</CodeContractAnalysisTargets>
</PropertyGroup>
<Import Project="$(CodeContractAnalysisTargets)" Condition="Exists('$(CodeContractAnalysisTargets)')"/>
<!-- End Microsoft Code Contracts -->
</Project>