Documentation
¶
Overview ¶
Package restore implements NuGet package restore operations. It provides functionality to restore packages from project files, resolve dependencies, and manage the package cache.
Package restore implements NuGet package restore operations. It provides functionality to restore packages from project files, resolve dependencies, and manage the package cache.
Index ¶
- Constants
- func CalculateDgSpecHash(proj *project.Project) (string, error)
- func CalculateDgSpecHashWithConfig(proj *project.Project, config *DgSpecConfig) (string, error)
- func FormatVersionNotFoundError(projectPath, packageID, versionConstraint string, versionInfos []VersionInfo, ...) string
- func GetCacheFilePath(projectPath string) string
- func Hash(data []byte) uint64
- func ResolveLatestVersion(ctx context.Context, packageID string, opts *ResolveLatestVersionOptions) (string, error)
- func Run(ctx context.Context, args []string, opts *Options, console Console) error
- type AssetsInfo
- type CacheFile
- type Console
- type DependencyInfo
- type DgSpecConfig
- type DgSpecHasher
- func (h *DgSpecHasher) GenerateJSON() ([]byte, error)
- func (h *DgSpecHasher) WithConfigPaths(paths []string) *DgSpecHasher
- func (h *DgSpecHasher) WithDownloadDependencies(deps map[string]map[string]string) *DgSpecHasher
- func (h *DgSpecHasher) WithFallbackFolders(folders []string) *DgSpecHasher
- func (h *DgSpecHasher) WithPackagesPath(path string) *DgSpecHasher
- func (h *DgSpecHasher) WithRuntimeIDPath(path string) *DgSpecHasher
- func (h *DgSpecHasher) WithSdkAnalysisLevel(level string) *DgSpecHasher
- func (h *DgSpecHasher) WithSources(sources []string) *DgSpecHasher
- type DiagnosticTracer
- type FnvHash64
- type FrameworkInfo
- type FrameworkResult
- type Info
- type Library
- type LocalDependencyProvider
- type LockFile
- type LockFileBuilder
- type LogMessage
- type NuGetError
- func NewPackageDownloadFailedError(projectPath, packageID, versionConstraint string, versionInfos []VersionInfo) *NuGetError
- func NewPackageNotFoundError(projectPath, packageID, version string, sources []string) *NuGetError
- func NewPackageVersionNotFoundError(projectPath, packageID, versionConstraint string, versionInfos []VersionInfo) *NuGetError
- type Options
- type OrderedJSONWriter
- type PackageFolder
- type PackageInfo
- type PerformanceTiming
- type ProjectFrameworkInfo
- type ProjectInfo
- type RealTTYDetector
- type ResolutionTracer
- func (t *ResolutionTracer) TraceAssetsGeneration(assets *AssetsInfo)
- func (t *ResolutionTracer) TraceDependencyDiscovered(parentID, dependencyID, constraint string, isDirect bool)
- func (t *ResolutionTracer) TraceDependencyGraph(directCount, transitiveCount int)
- func (t *ResolutionTracer) TraceFrameworkCheck(packageID, packageVersion string, framework string, compatible bool)
- func (t *ResolutionTracer) TracePackageResolution(packageID, constraint string, available []string, selected string, ...)
- func (t *ResolutionTracer) TracePackageSources(sources []string)
- func (t *ResolutionTracer) TracePerformanceBreakdown(timing *PerformanceTiming)
- func (t *ResolutionTracer) TraceProjectAnalysis(projectPath string, sdk string, targetFrameworks []string, packageCount int)
- type ResolveLatestVersionOptions
- type Restorer
- type Result
- type SourceInfo
- type TTYDetector
- type Target
- type TargetLibrary
- type TerminalStatus
- type VersionInfo
Constants ¶
const ( // CacheFileVersion matches NuGet.ProjectModel.CacheFile.CurrentVersion CacheFileVersion = 2 // CacheFileName matches NoOpRestoreUtilities.NoOpCacheFileName CacheFileName = "project.nuget.cache" )
const ( // NU1101: Unable to find package ErrorCodePackageNotFound = "NU1101" // NU1102: Unable to find package with version constraint ErrorCodePackageVersionNotFound = "NU1102" // NU1103: Unable to download package ErrorCodePackageDownloadFailed = "NU1103" // NU1605: Detected package downgrade ErrorCodePackageDowngrade = "NU1605" )
Common NuGet error codes (matching NuGet.Client)
Variables ¶
This section is empty.
Functions ¶
func CalculateDgSpecHash ¶
CalculateDgSpecHash computes dependency graph hash for a project. Matches DependencyGraphSpec.GetHash() in NuGet.Client.
Uses FNV-1a 64-bit hash algorithm (default in NuGet.Client since .NET 5). Reference: NuGet.ProjectModel/DependencyGraphSpec.cs GetHash() method
The hash is computed over the complete dependency graph specification JSON, ensuring 100% compatibility with dotnet restore cache files.
func CalculateDgSpecHashWithConfig ¶
func CalculateDgSpecHashWithConfig(proj *project.Project, config *DgSpecConfig) (string, error)
CalculateDgSpecHashWithConfig computes hash with custom configuration.
func FormatVersionNotFoundError ¶
func FormatVersionNotFoundError(projectPath, packageID, versionConstraint string, versionInfos []VersionInfo, errorCode string, colorize bool) string
FormatVersionNotFoundError formats multi-line version-not-found errors (NU1102 and NU1103) with per-source version information. Matches dotnet's exact formatting where each line has full project path prefix. When colorize is true (TTY output), error codes are displayed in bright red. When colorize is false (piped output), output is plain text.
func GetCacheFilePath ¶
GetCacheFilePath returns path to project.nuget.cache for a project. Matches NoOpRestoreUtilities.GetProjectCacheFilePath.
func ResolveLatestVersion ¶
func ResolveLatestVersion(ctx context.Context, packageID string, opts *ResolveLatestVersionOptions) (string, error)
ResolveLatestVersion finds the latest version of a package. Returns the latest stable version by default, or latest prerelease if Prerelease is true. Ported from NuGet.Protocol version resolution logic.
Types ¶
type AssetsInfo ¶
type AssetsInfo struct {
// ProjectAssetsFile is the path to project.assets.json
ProjectAssetsFile string
ProjectAssetsSize int64
PackageCount int
TargetFrameworks []string
// CacheFile is the path to project.nuget.cache
CacheFile string
CacheFileSize int64
DgSpecHash string
}
AssetsInfo holds information about generated restore output files.
type CacheFile ¶
type CacheFile struct {
// Version is always 2 (current cache format version)
Version int `json:"version"`
// DgSpecHash is base64-encoded hash of dependency graph spec
DgSpecHash string `json:"dgSpecHash"`
// Success indicates whether restore succeeded
Success bool `json:"success"`
// ProjectFilePath is absolute path to project file
ProjectFilePath string `json:"projectFilePath"`
// ExpectedPackageFiles lists .nupkg.sha512 paths that must exist
ExpectedPackageFiles []string `json:"expectedPackageFiles"`
// Logs contains warnings/errors from restore (for replay on cache hit)
Logs []LogMessage `json:"logs"`
}
CacheFile represents project.nuget.cache file structure. Matches NuGet.ProjectModel.CacheFile in NuGet.Client.
func IsCacheValid ¶
IsCacheValid checks if cache can be used (hash matches + files exist). Matches the logic in RestoreCommand.EvaluateCacheFile (line 1360).
func LoadCacheFile ¶
LoadCacheFile reads cache file from disk. Matches CacheFileFormat.Read in NuGet.Client.
func NewCacheFile ¶
NewCacheFile creates a new cache file with the given hash.
func (*CacheFile) IsValid ¶
IsValid returns true if cache file is valid (version matches and restore succeeded). Matches CacheFile.IsValid property in NuGet.Client.
func (*CacheFile) Save ¶
Save writes cache file to disk at the given path. Matches CacheFileFormat.Write in NuGet.Client.
func (*CacheFile) VerifyPackageFilesExist ¶
VerifyPackageFilesExist checks if all expected package files exist on disk. Matches NoOpRestoreUtilities.VerifyRestoreOutput in NuGet.Client.
type Console ¶
type Console interface {
Printf(format string, args ...any)
Error(format string, args ...any)
Warning(format string, args ...any)
Output() io.Writer
}
Console interface for output (injected from CLI).
type DependencyInfo ¶
DependencyInfo represents a package dependency.
type DgSpecConfig ¶
type DgSpecConfig struct {
PackagesPath string
FallbackFolders []string
Sources []string
ConfigPaths []string
RuntimeIDPath string
SdkAnalysisLevel string
}
DgSpecConfig holds configuration for dgSpec hash calculation.
func DefaultDgSpecConfig ¶
func DefaultDgSpecConfig() *DgSpecConfig
DefaultDgSpecConfig returns default configuration.
func DiscoverDgSpecConfig ¶
func DiscoverDgSpecConfig(proj *project.Project) (*DgSpecConfig, error)
DiscoverDgSpecConfig discovers configuration from project directory. Reads NuGet.config files and returns configuration matching dotnet's behavior.
type DgSpecHasher ¶
type DgSpecHasher struct {
// contains filtered or unexported fields
}
DgSpecHasher generates the exact JSON structure that NuGet.Client uses for dgSpecHash. Reference: NuGet.ProjectModel/DependencyGraphSpec.cs Write() method
func NewDgSpecHasher ¶
func NewDgSpecHasher(proj *project.Project) *DgSpecHasher
NewDgSpecHasher creates a hasher for a project.
func (*DgSpecHasher) GenerateJSON ¶
func (h *DgSpecHasher) GenerateJSON() ([]byte, error)
GenerateJSON generates the dgspec JSON for hashing. Matches DependencyGraphSpec.Write() with hashing: true.
CRITICAL: Key order must match NuGet.Client exactly for hash compatibility. NuGet writes: format, restore, projects (NOT alphabetical). Go's json.Marshal sorts keys alphabetically, so we use OrderedJSONWriter.
func (*DgSpecHasher) WithConfigPaths ¶
func (h *DgSpecHasher) WithConfigPaths(paths []string) *DgSpecHasher
WithConfigPaths sets the NuGet.config file paths.
func (*DgSpecHasher) WithDownloadDependencies ¶
func (h *DgSpecHasher) WithDownloadDependencies(deps map[string]map[string]string) *DgSpecHasher
WithDownloadDependencies sets the download dependencies map.
func (*DgSpecHasher) WithFallbackFolders ¶
func (h *DgSpecHasher) WithFallbackFolders(folders []string) *DgSpecHasher
WithFallbackFolders sets the fallback package folders.
func (*DgSpecHasher) WithPackagesPath ¶
func (h *DgSpecHasher) WithPackagesPath(path string) *DgSpecHasher
WithPackagesPath sets the global packages folder path.
func (*DgSpecHasher) WithRuntimeIDPath ¶
func (h *DgSpecHasher) WithRuntimeIDPath(path string) *DgSpecHasher
WithRuntimeIDPath sets the RuntimeIdentifierGraph.json path.
func (*DgSpecHasher) WithSdkAnalysisLevel ¶
func (h *DgSpecHasher) WithSdkAnalysisLevel(level string) *DgSpecHasher
WithSdkAnalysisLevel sets the SDK analysis level.
func (*DgSpecHasher) WithSources ¶
func (h *DgSpecHasher) WithSources(sources []string) *DgSpecHasher
WithSources sets the package sources.
type DiagnosticTracer ¶
type DiagnosticTracer interface {
// TracePackageResolution logs package version selection.
// Shows why a specific version was chosen from available versions.
TracePackageResolution(packageID, constraint string, available []string, selected string, reason string)
// TraceFrameworkCheck logs framework compatibility check.
TraceFrameworkCheck(packageID, packageVersion string, framework string, compatible bool)
// TraceDependencyDiscovered logs when a dependency is found.
TraceDependencyDiscovered(parentID, dependencyID, constraint string, isDirect bool)
// TraceDependencyGraph logs the final resolved graph.
TraceDependencyGraph(directCount, transitiveCount int)
// TraceProjectAnalysis logs project file details.
// Shows SDK, target frameworks, and package references.
TraceProjectAnalysis(projectPath string, sdk string, targetFrameworks []string, packageCount int)
// TracePackageSources logs active package sources.
// Shows which sources will be used for package resolution.
TracePackageSources(sources []string)
// TracePerformanceBreakdown logs detailed performance metrics.
// Shows timing for each phase and per-package operations.
TracePerformanceBreakdown(timing *PerformanceTiming)
// TraceAssetsGeneration logs generated output files.
// Shows file paths, sizes, and metadata about generated assets.
TraceAssetsGeneration(assets *AssetsInfo)
}
DiagnosticTracer captures restore operations for diagnostic output. This interface allows pluggable diagnostic implementations for different verbosity levels.
type FnvHash64 ¶
type FnvHash64 struct {
// contains filtered or unexported fields
}
FnvHash64 implements the FNV-1a 64-bit hash algorithm used by NuGet.Client. Reference: NuGet.ProjectModel/FnvHash64Function.cs
type FrameworkInfo ¶
type FrameworkInfo struct {
TargetAlias string `json:"targetAlias"`
ProjectReferences map[string]any `json:"projectReferences"`
}
FrameworkInfo represents framework-specific restore info (project references and restore metadata). Named FrameworkInfo rather than RestoreFrameworkInfo to avoid package name stuttering. Distinct from ProjectFrameworkInfo which holds package dependencies.
type FrameworkResult ¶
type FrameworkResult struct {
Framework string // Target framework string (e.g., "net6.0")
DirectPackages []PackageInfo // Packages explicitly listed for this framework
TransitivePackages []PackageInfo // Transitive dependencies for this framework
Errors []*NuGetError // NuGet errors encountered during this framework's restore
// contains filtered or unexported fields
}
FrameworkResult holds restore results for a specific target framework.
type Info ¶
type Info struct {
ProjectUniqueName string `json:"projectUniqueName"`
ProjectName string `json:"projectName"`
ProjectPath string `json:"projectPath"`
PackagesPath string `json:"packagesPath"`
OutputPath string `json:"outputPath"`
ProjectStyle string `json:"projectStyle"`
Sources map[string]SourceInfo `json:"sources"`
FallbackFolders []string `json:"fallbackFolders"`
ConfigFilePaths []string `json:"configFilePaths"`
OriginalTargetFrameworks []string `json:"originalTargetFrameworks"`
Frameworks map[string]FrameworkInfo `json:"frameworks"`
}
Info represents restore metadata.
type Library ¶
type Library struct {
Type string `json:"type"`
Path string `json:"path,omitempty"`
Files []string `json:"files,omitempty"`
}
Library represents a package library entry.
type LocalDependencyProvider ¶
type LocalDependencyProvider struct {
// contains filtered or unexported fields
}
LocalDependencyProvider reads package dependencies from locally cached packages. Matches NuGet.Client LocalV3FindPackageByIdResource behavior. Reference: NuGet.Protocol/LocalRepositories/LocalV3FindPackageByIdResource.cs (lines 247-302, 430-468)
func NewLocalDependencyProvider ¶
func NewLocalDependencyProvider(packagesFolder string) *LocalDependencyProvider
NewLocalDependencyProvider creates a new local dependency provider.
func (*LocalDependencyProvider) GetDependencies ¶
func (p *LocalDependencyProvider) GetDependencies( ctx context.Context, packageID string, packageVersion string, ) ([]resolver.DependencyGroup, string, error)
GetDependencies reads package dependencies from locally cached .nuspec file. Returns ALL dependency groups (not filtered by framework), along with the resolved version. Returns nil if package is not found locally (caller should try remote).
If packageVersion is a version range (e.g., "[2.10.0, )"), it will: 1. Enumerate all cached versions for packageID (matches GetVersionsCore lines 488-532) 2. Find the best matching version that satisfies the range (matches FindLibraryCoreAsync lines 274-277) 3. Return dependencies for that resolved version (matches GetDependencyInfoAsync lines 247-302)
Returns: (dependency groups, resolved version string, error)
type LockFile ¶
type LockFile struct {
Version int `json:"version"`
Targets map[string]Target `json:"targets"`
Libraries map[string]Library `json:"libraries"`
ProjectFileDependencyGroups map[string][]string `json:"projectFileDependencyGroups"`
PackageFolders map[string]PackageFolder `json:"packageFolders"`
Project ProjectInfo `json:"project"`
}
LockFile represents project.assets.json structure. Ported from NuGet.ProjectModel/LockFile/LockFile.cs
type LockFileBuilder ¶
type LockFileBuilder struct {
}
LockFileBuilder builds project.assets.json from restore results. Ported from NuGet.Commands/RestoreCommand/LockFileBuilder.cs
func NewLockFileBuilder ¶
func NewLockFileBuilder() *LockFileBuilder
NewLockFileBuilder creates a new lock file builder.
type LogMessage ¶
type LogMessage struct {
Code string `json:"code"` // NuGet error code (e.g., "NU1101")
Level string `json:"level"` // Log level: "Error", "Warning", "Information"
Message string `json:"message"` // Human-readable message
// Optional fields
ProjectPath string `json:"projectPath,omitempty"` // Project file path
FilePath string `json:"filePath,omitempty"` // File causing the issue
LibraryID string `json:"libraryId,omitempty"` // Package ID
TargetGraphs []string `json:"targetGraphs,omitempty"` // Affected target frameworks
// Line/column information (omitted if zero)
StartLineNumber int `json:"startLineNumber,omitempty"`
StartColumnNumber int `json:"startColumnNumber,omitempty"`
EndLineNumber int `json:"endLineNumber,omitempty"`
EndColumnNumber int `json:"endColumnNumber,omitempty"`
// WarningLevel is only relevant for warnings (0 = show no warnings, 1 = severe)
// Omitted from JSON if not a warning
WarningLevel int `json:"warningLevel,omitempty"`
}
LogMessage represents a log entry in the cache file. Matches NuGet.ProjectModel.IAssetsLogMessage in NuGet.Client.
type NuGetError ¶
type NuGetError struct {
Code string // Error code (e.g., "NU1101", "NU1102")
Message string // Error message
ProjectPath string // Absolute path to project file
Sources []string // Source URLs involved in the error (for NU1101)
VersionInfos []VersionInfo // Version information per source (for NU1102)
PackageID string // Package ID (for NU1102 formatting)
Constraint string // Version constraint (for NU1102 formatting)
}
NuGetError represents a NuGet-specific error with an error code.
func NewPackageDownloadFailedError ¶
func NewPackageDownloadFailedError(projectPath, packageID, versionConstraint string, versionInfos []VersionInfo) *NuGetError
NewPackageDownloadFailedError creates a NU1103 error for when only prerelease versions exist but stable requested.
func NewPackageNotFoundError ¶
func NewPackageNotFoundError(projectPath, packageID, version string, sources []string) *NuGetError
NewPackageNotFoundError creates a NU1101 error for a package that doesn't exist.
func NewPackageVersionNotFoundError ¶
func NewPackageVersionNotFoundError(projectPath, packageID, versionConstraint string, versionInfos []VersionInfo) *NuGetError
NewPackageVersionNotFoundError creates a NU1102 error for when a package exists but no compatible version is found.
func (*NuGetError) Error ¶
func (e *NuGetError) Error() string
Error implements the error interface. Formats NU1101 errors with indentation and ANSI colors to match dotnet output.
func (*NuGetError) FormatError ¶
func (e *NuGetError) FormatError(colorize bool) string
FormatError formats the error with optional ANSI color codes. When colorize is false, output is plain text (for piped output). When colorize is true, error codes are displayed in bright red (for TTY output).
type Options ¶
type Options struct {
Sources []string
PackagesFolder string
ConfigFile string
Force bool
NoCache bool
NoDependencies bool
Verbosity string
}
Options holds restore configuration.
type OrderedJSONWriter ¶
type OrderedJSONWriter struct {
// contains filtered or unexported fields
}
OrderedJSONWriter writes JSON with exact field order matching NuGet.Client. This is CRITICAL for hash compatibility - different field order = different hash.
func NewOrderedJSONWriter ¶
func NewOrderedJSONWriter() *OrderedJSONWriter
NewOrderedJSONWriter creates a new ordered JSON writer.
func (*OrderedJSONWriter) Bytes ¶
func (w *OrderedJSONWriter) Bytes() []byte
Bytes returns the generated JSON bytes.
func (*OrderedJSONWriter) WriteDgSpec ¶
func (w *OrderedJSONWriter) WriteDgSpec(hasher *DgSpecHasher)
WriteDgSpec writes the complete DgSpec JSON matching NuGet.Client's exact structure. Reference: DependencyGraphSpec.cs Write() method (lines 359-389)
type PackageFolder ¶
type PackageFolder struct {
}
PackageFolder represents a package folder location.
type PackageInfo ¶
type PackageInfo struct {
ID string
Version string
Path string
// IsDirect indicates if this is a direct dependency
IsDirect bool
}
PackageInfo holds package information.
type PerformanceTiming ¶
type PerformanceTiming struct {
// Phase timings
DependencyResolution time.Duration
PackageDownloads time.Duration
AssetsGeneration time.Duration
// Per-package resolution timing
ResolutionTimings map[string]time.Duration // packageID -> duration
// Per-package download timing
DownloadTimings map[string]time.Duration // packageID -> duration
CacheHits map[string]bool // packageID -> cache hit
}
PerformanceTiming holds detailed timing metrics for diagnostic output.
type ProjectFrameworkInfo ¶
type ProjectFrameworkInfo struct {
TargetAlias string `json:"targetAlias"`
Dependencies map[string]DependencyInfo `json:"dependencies"`
}
ProjectFrameworkInfo represents framework-specific project info (package dependencies). Named ProjectFrameworkInfo to distinguish from FrameworkInfo (restore metadata) and avoid conflicts.
type ProjectInfo ¶
type ProjectInfo struct {
Version string `json:"version"`
Restore Info `json:"restore"`
Frameworks map[string]ProjectFrameworkInfo `json:"frameworks"`
}
ProjectInfo represents project metadata in lock file.
type RealTTYDetector ¶
type RealTTYDetector struct{}
RealTTYDetector uses golang.org/x/term to detect real terminals
type ResolutionTracer ¶
type ResolutionTracer struct {
// contains filtered or unexported fields
}
ResolutionTracer implements DiagnosticTracer for dependency resolution tracing. Only active when verbosity is set to "diagnostic".
func NewResolutionTracer ¶
func NewResolutionTracer(console Console, verbosity string) *ResolutionTracer
NewResolutionTracer creates a new resolution tracer. Tracing is only enabled when verbosity is "diagnostic" or "diag".
func (*ResolutionTracer) TraceAssetsGeneration ¶
func (t *ResolutionTracer) TraceAssetsGeneration(assets *AssetsInfo)
TraceAssetsGeneration logs generated output files (diagnostic only).
func (*ResolutionTracer) TraceDependencyDiscovered ¶
func (t *ResolutionTracer) TraceDependencyDiscovered(parentID, dependencyID, constraint string, isDirect bool)
TraceDependencyDiscovered logs when a dependency is found (diagnostic only).
func (*ResolutionTracer) TraceDependencyGraph ¶
func (t *ResolutionTracer) TraceDependencyGraph(directCount, transitiveCount int)
TraceDependencyGraph logs the final resolved graph (diagnostic only).
func (*ResolutionTracer) TraceFrameworkCheck ¶
func (t *ResolutionTracer) TraceFrameworkCheck(packageID, packageVersion string, framework string, compatible bool)
TraceFrameworkCheck logs framework compatibility check (diagnostic only).
func (*ResolutionTracer) TracePackageResolution ¶
func (t *ResolutionTracer) TracePackageResolution(packageID, constraint string, available []string, selected string, reason string)
TracePackageResolution logs package version selection (diagnostic only).
func (*ResolutionTracer) TracePackageSources ¶
func (t *ResolutionTracer) TracePackageSources(sources []string)
TracePackageSources logs active package sources (diagnostic only).
func (*ResolutionTracer) TracePerformanceBreakdown ¶
func (t *ResolutionTracer) TracePerformanceBreakdown(timing *PerformanceTiming)
TracePerformanceBreakdown logs detailed performance metrics (diagnostic only).
func (*ResolutionTracer) TraceProjectAnalysis ¶
func (t *ResolutionTracer) TraceProjectAnalysis(projectPath string, sdk string, targetFrameworks []string, packageCount int)
TraceProjectAnalysis logs project file details (diagnostic only).
type ResolveLatestVersionOptions ¶
ResolveLatestVersionOptions holds options for version resolution.
type Restorer ¶
type Restorer struct {
// contains filtered or unexported fields
}
Restorer executes restore operations.
func NewRestorer ¶
NewRestorer creates a new restorer.
func (*Restorer) Restore ¶
func (r *Restorer) Restore( ctx context.Context, proj *project.Project, packageRefs []project.PackageReference, ) (*Result, error)
Restore executes the restore operation with full transitive dependency resolution. Matches NuGet.Client RestoreCommand behavior (line 572-616 GenerateRestoreGraphsAsync).
type Result ¶
type Result struct {
// DirectPackages contains packages explicitly listed in project file
DirectPackages []PackageInfo
// TransitivePackages contains packages pulled in as dependencies
TransitivePackages []PackageInfo
// FrameworkResults contains per-framework package lists (for multi-TFM projects)
// Maps framework string (e.g., "net6.0") to the packages resolved for that framework
FrameworkResults map[string]*FrameworkResult
// Graph contains full dependency graph (optional, for debugging)
Graph any // *resolver.GraphNode, but avoid import cycle
// CacheHit indicates restore was skipped (cache valid)
CacheHit bool
// Errors contains NuGet errors encountered during restore
Errors []*NuGetError
// PerformanceTiming holds detailed timing metrics (diagnostic mode only)
PerformanceTiming *PerformanceTiming
}
Result holds restore results.
func RunWithResult ¶
func RunWithResult(ctx context.Context, args []string, opts *Options, console Console) (*Result, error)
RunWithResult executes the restore operation and returns detailed results. This is used by interop tests to validate direct vs transitive package categorization.
func (*Result) AllPackages ¶
func (r *Result) AllPackages() []PackageInfo
AllPackages returns all packages (direct + transitive). Matches NuGet.Client's flattened package list from RestoreTargetGraph.
type TTYDetector ¶
type TTYDetector interface {
// IsTTY returns true if w is a terminal (not piped/redirected)
IsTTY(w io.Writer) bool
// GetSize returns the terminal width and height (columns, rows)
// Returns an error if w is not a terminal or size cannot be determined
GetSize(w io.Writer) (width, height int, err error)
}
TTYDetector detects whether an io.Writer is a terminal (TTY) and gets its dimensions. This interface allows mocking in tests.
var DefaultTTYDetector TTYDetector = &RealTTYDetector{}
DefaultTTYDetector is the default detector used in production
type Target ¶
type Target map[string]TargetLibrary
Target represents a target framework's dependency graph. Maps package ID/Version to target library info.
type TargetLibrary ¶
type TargetLibrary struct {
Type string `json:"type"`
Compile map[string]map[string]string `json:"compile,omitempty"` // Path to DLL -> metadata
Runtime map[string]map[string]string `json:"runtime,omitempty"` // Path to DLL -> metadata
}
TargetLibrary represents a package's assemblies and metadata for a specific target framework.
type TerminalStatus ¶
type TerminalStatus struct {
// contains filtered or unexported fields
}
TerminalStatus displays live restore status with right-aligned timer Matches MSBuild Terminal Logger behavior: - Updates at 30Hz (every ~33ms) - Right-aligned "Restore (X.Xs)" status - Hides cursor during updates to prevent flicker
func NewTerminalStatus ¶
func NewTerminalStatus(output io.Writer, projectName string, detector TTYDetector) *TerminalStatus
NewTerminalStatus creates a new terminal status updater If detector is nil, DefaultTTYDetector is used
func (*TerminalStatus) Elapsed ¶
func (t *TerminalStatus) Elapsed() time.Duration
Elapsed returns the elapsed time since start
func (*TerminalStatus) IsTTY ¶
func (t *TerminalStatus) IsTTY() bool
IsTTY returns true if output is a terminal (not piped/redirected)
func (*TerminalStatus) Stop ¶
func (t *TerminalStatus) Stop()
Stop stops the status updater and clears the status line Safe to call multiple times
type VersionInfo ¶
VersionInfo holds version information for NU1102 errors.