CodeContracts.MSBuild.v2 1.13.0

dotnet add package CodeContracts.MSBuild.v2 --version 1.13.0
NuGet\Install-Package CodeContracts.MSBuild.v2 -Version 1.13.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeContracts.MSBuild.v2" Version="1.13.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodeContracts.MSBuild.v2 --version 1.13.0
#r "nuget: CodeContracts.MSBuild.v2, 1.13.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodeContracts.MSBuild.v2 as a Cake Addin
#addin nuget:?package=CodeContracts.MSBuild.v2&version=1.13.0

// Install CodeContracts.MSBuild.v2 as a Cake Tool
#tool nuget:?package=CodeContracts.MSBuild.v2&version=1.13.0

CodeContracts.MSBuild.v2

Standalone MSBuild integration for Microsoft CodeContracts (by Microsoft Research).

Installation

Simply add CodeContracts.MSBuild.v2 nuget to projects that use Code Contracts.

From package manager:

Install-Package CodeContracts.MSBuild.v2

From .Net CLI:

dotnet add package CodeContracts.MSBuild.v2

Settings

DontOverrideCodeContractsInstallDir, CodeContractsInstallDir

By default CodeContracts.MSBuild.v2 uses CodeContracts version that is bundled with this package.

However, if you want to use custom CodeContracts installation, you can define the following MSBuild properties in your project file:

<PropertyGroup>
  <DontOverrideCodeContractsInstallDir>true<DontOverrideCodeContractsInstallDir>
  <CodeContractsInstallDir>your_custom_codecontracts_install_dir\</CodeContractsInstallDir>
</PropertyGroup>

CodeContracts*

CodeContracts.MSBuild.v2 defines a bunch of default properties that are used by Microsoft CodeContracts. Please refer to CodeContracts for meaning of these options.

Property Default value Description
Runtime checking
CodeContractsEnableRuntimeChecking False Runtime checking. If False, whole section is irrelevant.
CodeContractsAssemblyMode 1 Assembly mode, 1 = standard, 2 = advanced.
CodeContractsRuntimeCheckingLevel Full Level: Full, Pre and Post, Preconditions, ReleaseRequires, None
CodeContractsRuntimeOnlyPublicSurface False Only public surface contracts
CodeContractsRuntimeThrowOnFailure False Assert on contract failure
CodeContractsRuntimeCallSiteRequires False Call-site requires checking CodeContractsRuntimeSkipQuantifiers False Skip quantifiers
CodeContractsCustomRewriterAssembly empty Custom rewriter methods / Assembly
CodeContractsCustomRewriterClass empty Custom rewriter methods / Class
Static checking
CodeContractsRunCodeAnalysis True Static checking. If False, whole section is irrelevant.
CodeContractsNonNullObligations True Check non-null
CodeContractsEnumObligations True Check enum values
CodeContractsRedundantAssumptions True Check redundant assume
CodeContractsSuggestAssumptions False Show entry assumptions
CodeContractsSuggestRequires False Suggest requires
CodeContractsAssertsToContractsCheckBox True Suggest asserts to contracts
CodeContractsInferRequires True Infer requires
CodeContractsInferEnsures False Infer ensures
CodeContractsArithmeticObligations True Check arithmetic
CodeContractsMissingPublicRequiresAsWarnings True Check missing public requires
CodeContractsRedundantTests True Check redundant conditionals
CodeContractsSuggestAssumptionsForCallees False Show external assumptions
CodeContractsSuggestReadonly True Suggest readonly fields
CodeContractsNecessaryEnsures True Suggest necessary ensures
CodeContractsInferObjectInvariants False Infer invariants for readonly
CodeContractsInferEnsuresAutoProperties True Infer ensures for autoproperties
CodeContractsFailBuildOnWarnings False Fail build on warnings
CodeContractsBoundsObligations True Check array bounds
CodeContractsMissingPublicEnsuresAsWarnings False Check missing public ensures
CodeContractsSuggestObjectInvariants False Suggest object invariants
Misc
CodeContractsCacheAnalysisResults True Cache results
CodeContractsSQLServerOption empty SQL Server
CodeContractsSkipAnalysisIfCannotConnectToCache False Skip the analysis if cannot connect to cache
CodeContractsAnalysisWarningLevel 0 Warning level: 0, 1, 2, 3
CodeContractsBeingOptimisticOnExternal True Be optimistic on external API
CodeContractsUseBaseLine False Baseline
CodeContractsBaseLineFile empty Baseline file
CodeContractsReferenceAssembly Build Contract reference assembly
CodeContractsEmitXMLDocs False Emit contracts into XML doc file
Advanced options
CodeContractsLibPaths empty Extra contract library paths
CodeContractsExtraRewriteOptions empty Extra runtime checker options
CodeContractsExtraAnalysisOptions empty Extra static checker options
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.13.0 1,617 9/3/2019

Full changelog: https://github.com/Igorbek/CodeContracts.MSBuild/blob/master/CHANGELOG.md
1.13:
- Add support for Visual Studio 2019
1.12:
- Add .props file to initialize all contract default settings
- Marked package with developmentDependency
1.11:
- CodeContracts has been updated to v1.10.20606.1-rc2 (released on 6 Jun 2016)
- Improved .net targets support
1.10.1: Add .Net Framework 4.7.1 target support
1.10: Stop using pre-installed CodeContract by default.
1.9: CodeContracts has been updated to v1.9.10714.2 (released on 13 Jul 2015).