XDocumentExtensions Class

Summary

Several extension methods when using XDocument.
Assembly
Cake.Incubator.dll
Namespace
Cake.Incubator.XDocumentExtensions
Base Types
  • Object
graph BT Type-->Base0["Object"] Type["XDocumentExtensions"] class Type type-node

Syntax

public static class XDocumentExtensions

Methods

Name Value Summary
GetAssemblyReferences(XDocument, DirectoryPath) ICollection<ProjectAssemblyReference>
Returns all <Reference> entries declared in the project, resolving HintPath values relative to rootPath.
static
GetDotNetCliToolReferences(XDocument) ICollection<DotNetCliToolReference>
Returns all <DotNetCliToolReference> entries declared in the project.
static
GetFirstElementValue(XDocument, XName, string, string) string
gets the first matching element value, if a config is passed, it will only match an element with the specified config and platform condition. the platform defaults to AnyCPU
static
GetNuspecProps(XDocument) NameValueCollection
Returns the project's nuspec-relevant property values (PackageId, Title, Authors, Description, Copyright, etc.) keyed by element name.
static
GetOutputPaths(XDocument, string, string[], DirectoryPath, string) DirectoryPath[]
Gets the first output path value for a specific config from an xml document
static
GetPackageReferences(XDocument) ICollection<ParsedPackageReference>
Returns all <PackageReference> entries declared in the project, resolving PrivateAssets / IncludeAssets / ExcludeAssets attributes or child elements and any TargetFramework condition on the element or its parent ItemGroup.
static
GetProjectReferences(XDocument, DirectoryPath) ICollection<ProjectReference>
Returns all <ProjectReference> entries, resolving Include paths relative to rootPath.
static
GetSdk(XDocument) string
Returns the SDK identifier from the project's root element, supporting both the <Project Sdk="..."> attribute form and the <Project><Sdk Name="..." /></Project> child-element form (per #267 — common in monorepos that hide reusable SDK configuration in Directory.Build.props).
static
GetTargets(XDocument) ICollection<BuildTarget>
Returns all <Target> build targets declared in the project (with their BeforeTargets / AfterTargets attributes and nested <Exec> commands).
static
GetVersion(XDocument) string
Returns the project version, combining VersionPrefix and VersionSuffix when both are present, falling back to Version, and ultimately "1.0.0" when nothing is set.
static
GetXNameWithNamespace(XNamespace, string) XName
Combines an XNamespace with an element name into an XName, handling the case where the namespace is null (pre-VS2017 csproj files use a default namespace; modern SDK-style projects don't).
static
IsDotNetSdk(XDocument) bool
Checks if an xml document for the dot net sdk attribute
static

Extension Methods

Name Value Summary
ToDictionary() IDictionary<string, object>
Requires the Cake.DeployParams addin
ToStringWithNullMarkup() string
Returns the string value or a Not set> markup suitable for Spectre.Console.
Requires the Cake.Issues addin