ProjectParserExtensions.

HasPackage(CustomProjectParserResult, string, string) Method

Summary

Checks for a project package reference by name and optional TargetFramework

Syntax

public static bool HasPackage(this CustomProjectParserResult projectParserResult, string packageName, string targetFramework = null)

Examples

Checks if the project has an NUnit package
CustomParseProjectResult project 
        = ParseProject(new FilePath("test.csproj"), configuration: "Release", platform: "x86");
bool ref = project.HasReference("NUnit"); // true
bool ref = project.HasReference("NUnit", "net45"); // false

Parameters

Name Type Description
projectParserResult CustomProjectParserResult the parsed project
packageName string the package name
targetFramework string the target framework, if not specified, checks all TargetFrameworks for the package

Return Value

Type Description
bool True if package exists in project, otherwise false