msbuild

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 12 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 Link struct {
	Item, Include, Path, Dir string
	File                     string // the file the item is written in: the project, or a props file that applies to it
	Unresolved               bool
	Line                     int
	Condition                string // as PackageRef.Condition
}

Link is an item or import of a project that names a path outside the project's own folder: code or content the project builds in from elsewhere. Item is Compile, Content, None, EmbeddedResource or Import (dotnet.go also reports unresolved ProjectReferences as Links). Include as written; Path the resolved repo path (wildcards kept); Dir its folder, or the folder before the first wildcard segment. Unresolved: the path still holds something MSBuild computes ($(...), @(...), %(...)), or it leaves the repo; Path and Dir are empty.

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
	SDK         string            // the Sdk of <Project Sdk="…"> without /version, else the first <Sdk Name="…">; "" when none
	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
	Links       []Link // Compile, Content, None and EmbeddedResource items and Imports that reach outside the project's folder
	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
	File          string // the file the reference is written in
	Line          int
	Condition     string // as PackageRef.Condition
	Unresolved    bool
}

ProjectRef is one path of a ProjectReference that applies to the project (a ";" list gives one per part), written in the project or in a props, targets or imported file; either way MSBuild resolves it against the project's folder. Include as written; Path the resolved repo path, "" when it leaves the repo or is Unresolved. Unresolved: the path still holds something MSBuild computes ($(...), or a ";" a property brought in), or it is written outside the project and leaves the repo for this project.

Jump to

Keyboard shortcuts

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