|
5 | 5 | </PropertyGroup> |
6 | 6 |
|
7 | 7 | <!--===================================================================== |
8 | | - Begin Microsoft Code Contracts |
| 8 | + Begin Microsoft Code Contracts |
9 | 9 | ======================================================================--> |
10 | 10 |
|
11 | 11 | <PropertyGroup> |
12 | | - <CodeContractsDeclDir>$(OutDir)CodeContractsDeclarative\</CodeContractsDeclDir> |
| 12 | + <CodeContractsDeclDir>$(IntermediateOutputPath)Decl\</CodeContractsDeclDir> |
13 | 13 | <CodeContractsContractSubDir>CodeContracts\</CodeContractsContractSubDir> |
14 | 14 | <CodeContractsCCRefgenCommand>$(CodeContractsInstallDir)Bin\ccrefgen.exe</CodeContractsCCRefgenCommand> |
15 | 15 | </PropertyGroup> |
|
50 | 50 | <CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.0</CodeContractsReferenceAssemblyLibPath> |
51 | 51 | </PropertyGroup> |
52 | 52 | </When> |
53 | | - <When Condition="'$(TargetFrameworkVersion)' == 'v4.5'"> |
| 53 | + <When Condition="$(TargetFrameworkVersion.StartsWith('v4.5'))"> |
54 | 54 | <PropertyGroup> |
55 | 55 | <CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.5</CodeContractsReferenceAssemblyLibPath> |
56 | 56 | </PropertyGroup> |
57 | 57 | </When> |
58 | | - <When Condition="'$(TargetFrameworkVersion)' == 'v4.5.1'"> |
| 58 | + <When Condition="$(TargetFrameworkVersion.StartsWith('v4.'))"> |
59 | 59 | <PropertyGroup> |
60 | | - <CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.5</CodeContractsReferenceAssemblyLibPath> |
| 60 | + <CodeContractsReferenceAssemblyLibPath>$(CodeContractsInstallDir)Contracts\.NETFramework\v4.6</CodeContractsReferenceAssemblyLibPath> |
61 | 61 | </PropertyGroup> |
62 | 62 | </When> |
63 | 63 | <Otherwise> |
|
77 | 77 | VS property build pane picks it up and may persist it into the project |
78 | 78 | settings! |
79 | 79 | =====================================================================--> |
80 | | - |
| 80 | + |
81 | 81 | <PropertyGroup> |
82 | 82 | <CompileDependsOn>CodeContractsSlipInDefineSymbolDynamically;$(CompileDependsOn);CodeContractReferenceAssembly</CompileDependsOn> |
83 | 83 | </PropertyGroup> |
|
271 | 271 |
|
272 | 272 | <Target |
273 | 273 | Name="CodeContractReSign" |
274 | | - Condition="'$(DelaySign)' != 'true'" |
| 274 | + Condition="'$(DelaySign)' != 'true'" |
275 | 275 | > |
276 | 276 | <GetFrameworkSdkPath> |
277 | 277 | <Output |
278 | 278 | TaskParameter="Path" |
279 | 279 | PropertyName="CodeContractsSdkPath" /> |
280 | 280 | </GetFrameworkSdkPath> |
281 | 281 | <PropertyGroup> |
282 | | - <CodeContractsSnExe>"$(CodeContractsSdkPath)Bin\NETFX 4.0 Tools\sn.exe"</CodeContractsSnExe> |
| 282 | + <!-- SN is in the Framework SDK tools path, but TargetFrameworkSDKToolsDirectory isn't always available --> |
| 283 | + <CodeContractsSnExe Condition=" '$(TargetFrameworkSDKToolsDirectory)' != '' ">$(TargetFrameworkSDKToolsDirectory)sn.exe</CodeContractsSnExe> |
| 284 | + <CodeContractsSnExe Condition=" '$(TargetFrameworkSDKToolsDirectory)' == '' ">$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.6 Tools\sn.exe</CodeContractsSnExe> |
283 | 285 | </PropertyGroup> |
284 | 286 | <Exec |
285 | | - Condition="'$(KeyOriginatorFile)' != ''" |
286 | | - Command='$(CodeContractsSnExe) /R "@(IntermediateAssembly)" "$(KeyOriginatorFile)"' /> |
| 287 | + Condition="'$(KeyOriginatorFile)' != ''" |
| 288 | + Command='"$(CodeContractsSnExe)" /R "@(IntermediateAssembly)" "$(KeyOriginatorFile)"' /> |
287 | 289 | <Exec |
288 | | - Condition="'$(KeyContainerName)' != ''" |
289 | | - Command='$(CodeContractsSnExe) /Rc "@(IntermediateAssembly)" "$(KeyContainerName)"' /> |
| 290 | + Condition="'$(KeyContainerName)' != ''" |
| 291 | + Command='"$(CodeContractsSnExe)" /Rc "@(IntermediateAssembly)" "$(KeyContainerName)"' /> |
290 | 292 | </Target> |
291 | | - |
| 293 | + |
292 | 294 | <Target |
293 | 295 | Name="CodeContractInstrument" |
294 | 296 | Condition="'$(CodeContractsEnableRuntimeChecking)' == 'true' and '$(BuildingProject)'=='true'" |
|
374 | 376 | Name="MakeCodeContractOutputDirectory" |
375 | 377 | Condition="!Exists(@(CodeContractOutputDirectory))" |
376 | 378 | > |
377 | | - <Message |
| 379 | + <Message |
378 | 380 | Text="Making directory @(CodeContractOutputDirectory)" |
379 | 381 | /> |
380 | 382 | <MakeDir |
|
415 | 417 | Condition="!Exists('$(CodeContractsDeclDir)')" |
416 | 418 | Directories="$(CodeContractsDeclDir)"/> |
417 | 419 | </Target> |
418 | | - |
| 420 | + |
419 | 421 | <Target |
420 | 422 | Name="ContractDeclarativeAssemblyVB" |
421 | 423 | Condition="'$(Language)'=='VB'" |
|
431 | 433 | <Vbc Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' " |
432 | 434 | AdditionalLibPaths="$(AdditionalLibPaths)" |
433 | 435 | AddModules="@(AddModules)" |
434 | | - BaseAddress="$(BaseAddress)" |
| 436 | + BaseAddress="$(BaseAddress)" |
435 | 437 | CodePage="$(CodePage)" |
436 | 438 | DebugType="$(DebugType)" |
437 | 439 | DefineConstants="$(FinalDefineConstants),CONTRACTS_FULL=-1,CODE_ANALYSIS=-1" |
|
458 | 460 | OptionExplicit="$(OptionExplicit)" |
459 | 461 | OptionInfer="$(OptionInfer)" |
460 | 462 | OptionStrict="$(OptionStrict)" |
461 | | - OptionStrictType="$(OptionStrictType)" |
| 463 | + OptionStrictType="$(OptionStrictType)" |
462 | 464 | OutputAssembly="@(ContractDeclarativeAssembly)" |
463 | 465 | Platform="$(PlatformTarget)" |
464 | 466 | References="@(ReferencePath)" |
|
479 | 481 | WarningsAsErrors="" |
480 | 482 | WarningsNotAsErrors="$(WarningsNotAsErrors)" |
481 | 483 | Win32Icon="$(ApplicationIcon)" |
482 | | - Win32Manifest="$(Win32Manifest)" |
| 484 | + Win32Manifest="$(Win32Manifest)" |
483 | 485 | Win32Resource="$(Win32Resource)" |
484 | 486 | /> |
485 | | - |
| 487 | + |
486 | 488 | <ItemGroup> |
487 | 489 | <FileWrites |
488 | 490 | Include="@(ContractDeclarativeAssemblies)"/> |
|
528 | 530 | NoWin32Manifest="$(NoWin32Manifest)" |
529 | 531 | Optimize="true" |
530 | 532 | OutputAssembly="@(ContractDeclarativeAssembly)" |
531 | | - PdbFile="@(ContractDeclarativeAssemblyPDB)" |
| 533 | + PdbFile="@(ContractDeclarativeAssemblyPDB)" |
532 | 534 | Platform="$(PlatformTarget)" |
533 | 535 | References="@(ReferencePath)" |
534 | 536 | Resources="" |
|
546 | 548 | Win32Icon="" |
547 | 549 | Win32Manifest="$(Win32Manifest)" |
548 | 550 | Win32Resource="$(Win32Resource)" |
549 | | - /> |
550 | | - |
| 551 | + /> |
| 552 | + |
551 | 553 | <ItemGroup> |
552 | 554 | <FileWrites |
553 | 555 | Include="@(ContractDeclarativeAssemblies)"/> |
|
628 | 630 | /> |
629 | 631 |
|
630 | 632 | <Exec |
631 | | - Command='"$(CodeContractsCCdocgenCommand)" "@$(IntermediateOutputPath)$(ProjectName)ccdocgen.rsp"' |
| 633 | + Command='"$(CodeContractsCCdocgenCommand)" "@$(IntermediateOutputPath)$(ProjectName)ccdocgen.rsp"' |
632 | 634 | /> |
633 | 635 | </Target> |
634 | 636 |
|
635 | 637 | <!--===================================================================== |
636 | | - Include Code Analysis target if present |
| 638 | + Register built contract assembly with project outputs |
637 | 639 | ======================================================================--> |
638 | 640 | <PropertyGroup> |
639 | | - <CodeContractAnalysisTargets>$(CodeContractsInstallDir)MsBuild\v4.0\Microsoft.CodeContractAnalysis.targets</CodeContractAnalysisTargets> |
| 641 | + <BuiltProjectOutputGroupDependsOn>$(BuiltProjectOutputGroupDependsOn);_IncludeCodeContractIntoBuiltProjectOutputGroup</BuiltProjectOutputGroupDependsOn> |
640 | 642 | </PropertyGroup> |
641 | | - <Import Project="$(CodeContractAnalysisTargets)" Condition="Exists('$(CodeContractAnalysisTargets)')"/> |
| 643 | + |
| 644 | + <Target |
| 645 | + Name="_IncludeCodeContractIntoBuiltProjectOutputGroup" |
| 646 | + Condition="'$(TargetName)' != 'Microsoft.Contracts' and '$(CodeContractsReferenceAssembly)' == 'build'"> |
| 647 | + <ItemGroup> |
| 648 | + <BuiltProjectOutputGroupOutput Include="@(ContractReferenceAssemblyAbsolute)"> |
| 649 | + <TargetPath>$(CodeContractsContractSubDir)%(Filename)%(Extension)</TargetPath> |
| 650 | + <FinalOutputPath>%(FullPath)</FinalOutputPath> |
| 651 | + <OriginalItemSpec>%(FullPath)</OriginalItemSpec> |
| 652 | + </BuiltProjectOutputGroupOutput> |
| 653 | + </ItemGroup> |
| 654 | + </Target> |
| 655 | + |
| 656 | + <!--===================================================================== |
| 657 | + Include Code Analysis target |
| 658 | + ======================================================================--> |
| 659 | + <Import Project="Microsoft.CodeContractAnalysis.targets" /> |
642 | 660 |
|
643 | 661 | <!-- End Microsoft Code Contracts --> |
644 | 662 | </Project> |
0 commit comments