Documentation
¶
Overview ¶
Package msbuild reads .NET project files the way MSBuild evaluates the parts Cernly needs: project discovery, SDK-style detection, the Directory.Build.props and Directory.Packages.props chain, properties, PackageReference, ProjectReference and packages.config. It never runs MSBuild: what it cannot determine stays as written and is marked unresolved.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyCondition ¶
AnyCondition is the condition under which one of several items with these conditions applies: "" when any is unconditional, else the distinct ones joined with " or ", each in parentheses when there are several.
Types ¶
type Candidate ¶
Candidate is one version source (a Version, VersionOverride, PackageVersion or Update) that may apply to a PackageRef: its raw version, the condition it is under ("" when unconditional or decided true), and its line.
type PackageRef ¶
type PackageRef struct {
ID, Version string // Version as resolved; raw when unresolved; "" when several Candidates remain
Raw string // as written
Unresolved bool
Candidates []Candidate // the version sources that may apply, in source order, when no single one is decided
Condition string // the Conditions of the item and its enclosing groups and Whens, joined with " and "; empty when decided true (condition.go)
PrivateAll bool // PrivateAssets="all" (attribute or child)
Global bool // from GlobalPackageReference
Ev []fact.Evidence // the reference line, plus the PackageVersion line when CPM supplied it
}
type PackagesConfigEntry ¶
func PackagesConfig ¶
func PackagesConfig(r *repo.Repo, file string) ([]PackagesConfigEntry, error)
PackagesConfig reads a packages.config: one entry per <package>.
type Project ¶
type Project struct {
Path, Dir string // repo paths, "/" separators
Lang string // csharp | fsharp | vb, from the extension
SDKStyle bool
Name string // file name without extension
Props map[string]string // lower-cased name -> value: the Directory.Build.props chain, then Directory.Packages.props, then the project (project wins); conditional or unresolvable properties are absent
Packages []PackageRef
ProjectRefs []ProjectRef
CPM bool // ManagePackageVersionsCentrally resolved true
IsTest bool // IsTestProject true, or references Microsoft.NET.Test.Sdk unconditionally
}
func Projects ¶
func Projects(r *repo.Repo) ([]*Project, []fact.LocationError)
Projects reads every tracked .csproj, .fsproj and .vbproj, sorted by path. A file that does not parse is left out and reported; a props file that does not parse is reported once and contributes nothing.
Evaluation follows MSBuild's order: the nearest Directory.Build.props (and the parents it imports with GetPathOfFileAbove), the nearest Directory.Packages.props likewise, then the project; all properties before any item. A property set under a Condition is unknown from then on, until an unconditional one sets it again. A Choose takes its first true When, or Otherwise, decided where it stands (choose). An item condition that can be decided exactly against those properties (condition.go) drops the item or becomes empty; any other stays as written. Several conditional version sources leave the version empty with every Candidate listed. Props files outside the repo are never seen.