msbuild

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func AnyCondition(conds []string) string

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

type Candidate struct {
	Raw, Condition string
	Ev             fact.Evidence
}

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

type PackagesConfigEntry struct {
	ID, Version string
	Dev         bool
	Line        int
}

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.

type ProjectRef

type ProjectRef struct {
	Include, Path string
	Line          int
	Condition     string // as PackageRef.Condition

} // Include as written, Path resolved repo path ("" when it leaves the repo)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL