Snyk CLI for .NET
To analyze Open Source libraries, install your dependencies, then run snyk test using one of the following options:
--file=: Targets a specific solution file (.sln) or Project file.--all-projects: Analyzes all Open Source Projects. Use this for Projects with multiple languages, package managers, or.slnfiles.
To perform source code analysis, run snyk code test from the root of the Project.
NuGet
For NuGet-specific options, visit Options for NuGet projects in the Test help and Options for NuGet projects in the Monitor help.
Snyk scans NuGet Projects using the project.assets.json file. Snyk supports the following Project files that resolve into project.assets.json:
*.csproj*.vbproj*.fsproj
To scan a NuGet Project:
Run
dotnet restore. This restores dependencies and creates theobj/project.assets.jsonfile.Run
snyk test.
You must run dotnet restore before snyk test to restore dependencies and ensure accurate scan results.
Support for project.json
Snyk supports project.json files, although Microsoft no longer recommends this format.
Support for packages.config
Snyk supports packages.config files. To scan these Projects:
Run
nuget install -OutputDirectory packagesto install dependencies into thepackagesfolder.Ensure the command created the
packagesdirectory.Run
snyk testas follows:Install the dependencies into the packages folder by running
nuget install -OutputDirectory packagesEnsure that the packages directory has been created by the previous command.
Run
snyk test.
Paket
To use Paket with the Snyk CLI:
Ensure your project contains a
paket.lockfile and apaket.dependenciesfile.Run
snyk test.
Options and plugins
snyk-to-html: Generates reports locally or at build time.
--jsonand--sarif: Generates output for programmatic access.snyk-filter: Provides advanced filtering options.
Last updated
Was this helpful?

