ProjectParserExtensions.

GetPackage(CustomProjectParserResult, string, string) Method

Summary

Gets a project package reference

Syntax

public static ParsedPackageReference GetPackage(this CustomProjectParserResult projectParserResult, string packageName, string targetFramework = null)

Examples

Get the NUnit package reference
 CustomParseProjectResult project 
         = ParseProject(new FilePath("test.csproj"), configuration: "Release", platform: "x86");
 
 ParsedPackageReference ref = project.GetReference("NUnit");
 string nUnitVersion = ref.Version;

 ParsedPackageReference ref = project.GetReference("NUnit", "netstandard2.0");
 string nUnitVersion = ref.Version;

Parameters

Name Type Description
projectParserResult CustomProjectParserResult the parsed project
packageName string the package name
targetFramework string the specific targetframework, if not specified, returns the package for any TargetFramework

Return Value

Type Description
ParsedPackageReference The package reference if found