dotnet

package
v1.23.13 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SingleFileAspireHostName is the required filename for single-file Aspire AppHosts
	SingleFileAspireHostName = "apphost.cs"
	// AspireSdkDirective is the SDK directive that must be present in single-file Aspire AppHosts
	AspireSdkDirective = "#:sdk Aspire.AppHost.Sdk"
)

Constants for Aspire AppHost detection

Variables

View Source
var DotNetProjectExtensions = []string{".csproj", ".fsproj", ".vbproj"}

DotNetProjectExtensions lists all valid .NET project file extensions

Functions

This section is empty.

Types

type Cli

type Cli struct {
	// contains filtered or unexported fields
}

func NewCli

func NewCli(commandRunner exec.CommandRunner) *Cli

func (*Cli) Build

func (cli *Cli) Build(ctx context.Context, project string, configuration string, output string, env []string) error

func (*Cli) BuildContainerLocal

func (cli *Cli) BuildContainerLocal(
	ctx context.Context, project, configuration, imageName string,
) (int, string, error)

PublishContainer runs a `dotnet publish" with `/t:PublishContainer`to build and publish the container. It also gets port number by using `--getProperty:GeneratedContainerConfiguration`. For single-file apps (.cs files), it runs from the file's directory to properly resolve relative references. BuildContainerLocal runs `dotnet publish` with `/t:PublishContainer` to build a container image locally without pushing to a registry. Returns the port number and image name.

func (*Cli) CheckInstalled

func (cli *Cli) CheckInstalled(ctx context.Context) error

func (*Cli) GetMsBuildProperty

func (cli *Cli) GetMsBuildProperty(ctx context.Context, project string, propertyName string) (string, error)

GetMsBuildProperty uses -getProperty to fetch a property after evaluation, without executing the build.

This only works for versions dotnet >= 8, MSBuild >= 17.8. On older tool versions, this will return an error.

func (*Cli) GitIgnore

func (cli *Cli) GitIgnore(ctx context.Context, projectPath string, options *GitIgnoreOptions) error

func (*Cli) InitializeSecret

func (cli *Cli) InitializeSecret(ctx context.Context, project string) error

func (*Cli) InstallUrl

func (cli *Cli) InstallUrl() string

func (*Cli) IsAspireHostProject

func (cli *Cli) IsAspireHostProject(ctx context.Context, projectPath string) (bool, error)

IsAspireHostProject returns true if the project at the given path has an MS Build Property named "IsAspireHost" which is set to true or has a ProjectCapability named "Aspire". For single-file apphost (apphost.cs), it validates them without running msbuild.

func (*Cli) IsSingleFileAspireHost

func (cli *Cli) IsSingleFileAspireHost(filePath string) (bool, error)

IsSingleFileAspireHost checks if the given file is a single-file Aspire AppHost. The caller should verify the filename matches SingleFileAspireHostName before calling this function. A file-based Aspire AppHost must meet all of these conditions: 1. File name: Must be named apphost.cs (case-insensitive) - verified by caller 2. No sibling .NET project files: The directory must NOT contain .csproj, .fsproj, or .vbproj files 3. SDK Directive: Must contain the AspireSdkDirective in the file content

func (*Cli) Name

func (cli *Cli) Name() string

func (*Cli) Publish

func (cli *Cli) Publish(ctx context.Context, project string, configuration string, output string, env []string) error

func (*Cli) PublishAppHostManifest

func (cli *Cli) PublishAppHostManifest(
	ctx context.Context, hostProject string, manifestPath string, dotnetEnv string,
) error

func (*Cli) PublishContainer

func (cli *Cli) PublishContainer(
	ctx context.Context, project, configuration, imageName, server, username, password string,
) (int, error)

func (*Cli) Restore

func (cli *Cli) Restore(ctx context.Context, project string, env []string) error

func (*Cli) SetSecrets

func (cli *Cli) SetSecrets(ctx context.Context, secrets map[string]string, project string) error

type GitIgnoreIfExistsStrategy

type GitIgnoreIfExistsStrategy string
const (
	// GitIgnoreIfExistsStrategySkip skips creating the .gitignore file if it already exists. This is the default behavior.
	GitIgnoreIfExistsStrategySkip GitIgnoreIfExistsStrategy = "skip"
	// GitIgnoreIfExistsStrategyOverwrite overwrites the existing .gitignore file.
	GitIgnoreIfExistsStrategyOverwrite GitIgnoreIfExistsStrategy = "overwrite"
)

type GitIgnoreOptions

type GitIgnoreOptions struct {
	// IfExistsStrategy determines what to do if the .gitignore file already exists. Default is Skip.
	IfExistsStrategy GitIgnoreIfExistsStrategy
}

Jump to

Keyboard shortcuts

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