Skip to content

PostgresProjectSettings

Namespace: Ankus.PgConfig

Assembly: Ankus.PgConfig.dll

Reads a project’s evaluated PostgreSQL selection without building the extension.

public sealed class PostgresProjectSettings

Inheritance: object

Gets whether the evaluated project explicitly selected PostgresMajor. When false and PgConfigPath is set, callers use the executable’s reported major.

public bool HasExplicitPostgresMajor { get; }

Value: bool

Gets the selected pg_config executable, or null when ordinary installation discovery applies. Relative file paths are resolved against the project directory; executable names retain PATH lookup.

public string? PgConfigPath { get; }

Value: string

Gets the PostgreSQL major selected by the evaluated project, or 18 when none is declared.

public int PostgresMajor { get; }

Value: int

ReadAsync(string, string, IReadOnlyDictionary<string, string>, int?, CancellationToken)

Section titled “ReadAsync(string, string, IReadOnlyDictionary<string, string>, int?, CancellationToken)”

Evaluates project selection with the same global properties as the eventual build.

public static Task<PostgresProjectSettings> ReadAsync(string projectPath, string configuration, IReadOnlyDictionary<string, string> globalProperties, int? postgresMajor = null, CancellationToken cancellationToken = default)

Parameters:

projectPath — string

The project files to evaluate.

configuration — string

The effective build configuration.

globalProperties — IReadOnlyDictionary<string, string>

Literal global properties inherited by evaluated project references.

postgresMajor — int?

An explicit PostgreSQL major, or null for evaluated defaults.

cancellationToken — CancellationToken

Cancels evaluation and joins the query processes.

Returns: Task<PostgresProjectSettings>

The evaluated PostgreSQL selection.

ReadAsync(string, string, int?, CancellationToken)

Section titled “ReadAsync(string, string, int?, CancellationToken)”

Evaluates the project’s PostgreSQL properties with the installed .NET SDK and selected configuration. Imports, conditions and automatic response files participate; build targets run only when requested by the response file. A test project without its own selection inherits an unambiguous selection from its project references.

public static Task<PostgresProjectSettings> ReadAsync(string projectPath, string configuration, int? postgresMajor = null, CancellationToken cancellationToken = default)

Parameters:

projectPath — string

The extension project file.

configuration — string

The MSBuild configuration used for the eventual publication.

postgresMajor — int?

An explicit major supplied by the calling build, or null to use project defaults.

cancellationToken — CancellationToken

Cancels evaluation and joins the query process before returning.

Returns: Task<PostgresProjectSettings>

The evaluated PostgreSQL selection.

TryReadAsync(IEnumerable<string>, string, IReadOnlyDictionary<string, string>, int?, CancellationToken)

Section titled “TryReadAsync(IEnumerable<string>, string, IReadOnlyDictionary<string, string>, int?, CancellationToken)”

Evaluates project selection with the same global properties as the eventual build.

public static Task<PostgresProjectSettings?> TryReadAsync(IEnumerable<string> projectPaths, string configuration, IReadOnlyDictionary<string, string> globalProperties, int? postgresMajor = null, CancellationToken cancellationToken = default)

Parameters:

projectPaths — IEnumerable<string>

The project files to evaluate.

configuration — string

The effective build configuration.

globalProperties — IReadOnlyDictionary<string, string>

Literal global properties inherited by evaluated project references.

postgresMajor — int?

An explicit PostgreSQL major, or null for evaluated defaults.

cancellationToken — CancellationToken

Cancels evaluation and joins the query processes.

Returns: Task<PostgresProjectSettings>

The evaluated PostgreSQL selection.

Exceptions:

TryReadAsync(IEnumerable<string>, string, int?, CancellationToken)

Section titled “TryReadAsync(IEnumerable<string>, string, int?, CancellationToken)”

Reads a shared selection across evaluated projects without allowing an ambiguous reference chain to select a server.

public static Task<PostgresProjectSettings?> TryReadAsync(IEnumerable<string> projectPaths, string configuration, int? postgresMajor = null, CancellationToken cancellationToken = default)

Parameters:

projectPaths — IEnumerable<string>

The project files in the selected solution.

configuration — string

The effective MSBuild configuration.

postgresMajor — int?

An explicit global major, or null for declared defaults.

cancellationToken — CancellationToken

Cancels evaluation and joins the query processes.

Returns: Task<PostgresProjectSettings>

The shared declared selection, or null for an empty or unrelated group.

Exceptions:

TryReadAsync(string, string, IReadOnlyDictionary<string, string>, int?, CancellationToken)

Section titled “TryReadAsync(string, string, IReadOnlyDictionary<string, string>, int?, CancellationToken)”

Evaluates project selection with the same global properties as the eventual build.

public static Task<PostgresProjectSettings?> TryReadAsync(string projectPath, string configuration, IReadOnlyDictionary<string, string> globalProperties, int? postgresMajor = null, CancellationToken cancellationToken = default)

Parameters:

projectPath — string

The project files to evaluate.

configuration — string

The effective build configuration.

globalProperties — IReadOnlyDictionary<string, string>

Literal global properties inherited by evaluated project references.

postgresMajor — int?

An explicit PostgreSQL major, or null for evaluated defaults.

cancellationToken — CancellationToken

Cancels evaluation and joins the query processes.

Returns: Task<PostgresProjectSettings>

The evaluated PostgreSQL selection.

Exceptions:

TryReadAsync(string, string, int?, CancellationToken)

Section titled “TryReadAsync(string, string, int?, CancellationToken)”

Reads an unambiguous evaluated selection without assigning defaults to unrelated projects.

public static Task<PostgresProjectSettings?> TryReadAsync(string projectPath, string configuration, int? postgresMajor = null, CancellationToken cancellationToken = default)

Parameters:

projectPath — string

The project file whose imports and references participate.

configuration — string

The effective MSBuild configuration.

postgresMajor — int?

An explicit global major, or null for declared defaults.

cancellationToken — CancellationToken

Cancels evaluation and joins the query process.

Returns: Task<PostgresProjectSettings>

The selected installation, or null when no selection is declared.

Exceptions:

Invalid property values, conflicting selections, broken imports and circular references remain errors. A caller can use an absent declaration to apply its documented default.