Commands for installing .NET CodeContracts without prompts, removing it again and detecting it from deployment tools. A command is shown only when it is certain: from the manifest or the installer technology’s documented default.
Related guide: Silent install switches: MSI, NSIS, Inno Setup · Uninstall a program with the registry or PowerShell
With winget
PowerShell
winget install --id Microsoft.DotNet.CodeContracts -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id Microsoft.DotNet.CodeContracts -e --silentwinget uninstall --id Microsoft.DotNet.CodeContracts -e --silentBy installer
32-bit · MSI · en-US
Silent install
msiexec /i Contracts.devlab9ts.msi /qn /norestartWrite a log
msiexec /i Contracts.devlab9ts.msi /qn /norestart /l*v "%TEMP%\net-codecontracts-install.log"Uninstall
msiexec /x {4ED22F53-768D-4286-9F55-4927F1D67B4F} /qn /norestart- MSI product code
- {4ED22F53-768D-4286-9F55-4927F1D67B4F}
- Uninstall registry key
- HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{4ED22F53-768D-4286-9F55-4927F1D67B4F}
PowerShell: download, verify, install
Downloads the official file, checks its SHA256 and installs it silently.
install-net-codecontracts.ps1
$url = 'https://github.com/microsoft/CodeContracts/releases/download/v1.10.20606.1/Contracts.devlab9ts.msi'
$sha256 = '5A2E44751A650A8442DFE1A41484E960B46EAA1A55B25672F6537A1D59015F5B'
$file = Join-Path $env:TEMP 'Contracts.devlab9ts.msi'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Start-Process msiexec.exe -ArgumentList '/i', ('"{0}"' -f $file), '/qn', '/norestart' -Wait