CLI support for .NET
How to test .NET Projects with the Snyk CLI, including open source analysis with solution and project files and source code scanning
Last updated
Was this helpful?
How to test .NET Projects with the Snyk CLI, including open source analysis with solution and project files and source code scanning
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 .sln files.
To perform source code analysis, run snyk code test from the root of the Project.
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 the obj/project.assets.json file.
Run snyk test.
You must run dotnet restore before snyk test to restore dependencies and ensure accurate scan results.
Snyk supports project.json files, although Microsoft no longer recommends this format.
Snyk supports packages.config files. To scan these Projects:
Run nuget install -OutputDirectory packages to install dependencies into the packages folder.
Ensure the command created the packages directory.
Run snyk test as follows:
Install the dependencies into the packages folder by running nuget install -OutputDirectory packages
Ensure that the packages directory has been created by the previous command.
Run snyk test.
To use Paket with the Snyk CLI:
Ensure your project contains a paket.lock file and a paket.dependencies file.
Run snyk test.
snyk-to-html: Generates reports locally or at build time.
--json and --sarif: Generates output for programmatic access.
snyk-filter: Provides advanced filtering options.
Last updated
Was this helpful?
Was this helpful?

