.NET
editMSBuild projects
Every *.*proj file (.csproj, .vcxproj, .sqlproj, .wixproj, .esproj, ...) except the non-MSBuild .pbxproj and .vdproj, and every .props and .targets file, is scanned by MsBuildReferencesDependencyScanner:
| Written as | Reported as |
|---|---|
PackageReference, PackageDownload, GlobalPackageReference, with Version or VersionOverride | NuGet |
PackageVersion (central package management) | NuGet |
Sdk="Name/Version", <Sdk Name="..." Version="..." />, <Import Sdk="..." Version="..." /> | NuGet |
TargetFramework, TargetFrameworks, TargetFrameworkVersion | DotNetTargetFramework, with no name |
ProjectReference | MSBuildProjectReference, with no version |
- Like MSBuild, item types, metadata names and property names are case-insensitive (
<packagereference Include="A" version="1.0.0" />), while keywords such asItemGroupandIncludeare not. - An
IncludeorUpdatelist, such asInclude="A;B", is reported as one dependency per item, and names and versions are trimmed. When an item declares several packages, their shared version is not updatable. - An SDK without a version (
Sdk="Microsoft.NET.Sdk") is not reported: its version is built in or comes fromglobal.json. - A version or a target framework that references a property, such as
Version="$(XunitVersion)", is resolved when the file defines the property once, in aPropertyGroupof the project without condition, with a literal value. The version location is the definition of the property, shared by every dependency that uses it. A property defined in another file, such asDirectory.Build.props, defined with a condition, in a target or underChoose, or defined from other properties, is not resolved. Property functions ($([System.DateTime]::Now)) and item lists (@(Items)) are not resolved either. See Properties and variables.
packages.config
packages.config and packages.<project>.config are scanned by PackagesConfigDependencyScanner:
- A
packages.<project>.configfile is associated with the<project>.*projproject of the same folder, andpackages.configwith the other projects of the folder. The package paths of the associated projects (HintPath,ImportandError) are reported too, as more NuGet dependencies located in the project file, when the<id>.<version>folder is a whole path segment. Set SearchForReferencesInAssociatedCsprojFiles tofalseon the scanner to skip the projects. - The assembly version of a
Reference(Include="Name, Version=1.0.0.0") is not the package version: it is not reported as a dependency, and it is not changed when the package version is updated. It is in Dependency.Metadata under theassemblyVersionkey, and its location, which accepts only valid assembly versions, under theassemblyVersionLocationkey.
Other .NET files
| File | Scanner | Reported |
|---|---|---|
.nuspec | NuSpecDependencyScanner | The dependency elements, as NuGet. A dependency without a version is reported without a version |
global.json | DotNetGlobalJsonDependencyScanner | sdk.version as DotNetSdk, with no name, and the msbuild-sdks as NuGet |
dotnet-tools.json | DotNetToolManifestDependencyScanner | The local tools, as NuGet |
project.json | ProjectJsonDependencyScanner | The dependencies and tools, as NuGet |
packages.lock.json, packages.<project>.lock.json | NuGetLockFileDependencyScanner | The resolved packages, once per package and version, not updatable |
project.assets.json | ProjectAssetsDependencyScanner | The resolved packages, once per package and version, not updatable |
File-based apps
.cs files are scanned by DotNetFileBasedAppDependencyScanner for the #: directives of file-based apps:
| Directive | Reported as |
|---|---|
#:package Name@Version, or with Version or VersionOverride metadata | NuGet |
#:sdk Name@Version | NuGet |
#:property TargetFramework=Value | DotNetTargetFramework |
#:project Path | MSBuildProjectReference |
#:ref Path | DotNetAssemblyReference |
A version that references a property, such as #:package xunit.v3@$(XunitVersion), is resolved when a #:property XunitVersion=3.0.0 directive of the file defines it once with a literal value, even after the reference. The version location is the value of the #:property directive. See Properties and variables.
Like the .NET SDK, the directives are read until the first token of the file. Comments and other preprocessor directives (#nullable, #region, #pragma, ...) do not stop the scan, but #if does. An SDK without a version (#:sdk Name) is not reported.