Skip to content

Add configuration and framework config to .NET hook executor #7694

Description

@wbreza

Add configuration and framework config to .NET hook executor

Background & Motivation
The .NET hook executor builds with an empty configuration (SDK default = Debug), while the framework service hardcodes Release. Users need control over the build configuration for hook scripts, especially for production seed/migration hooks. Multi-targeting users also need to specify a target framework moniker. Issue #7653 explicitly calls out both properties.

User Story
As a .NET developer, I want to specify configuration and framework in my hook config so that my .NET hooks build and run with the correct settings.

Solution Approach

  • Define a strongly-typed dotnetHookConfig struct and unmarshal from execCtx.Config:
    type dotnetHookConfig struct {
        Configuration string `json:"configuration"` // Debug, Release, or custom
        Framework     string `json:"framework"`     // net8.0, net10.0, etc.
    }
  • Read config in dotnet_executor.go Prepare() phase via execCtx.Config
  • Pass Configuration to dotnetCli.Build() instead of empty string
  • Pass Framework as --framework flag to dotnet run in Execute() phase
  • Validate both are strings (no enum restriction for Configuration — MSBuild allows custom values like Staging)

Example azure.yaml

hooks:
  postprovision:
    run: ./hooks/migrate.cs
    kind: dotnet
    config:
      configuration: Release
      framework: net10.0

Acceptance Criteria

  • config.configuration: Release builds hook script in Release mode
  • config.configuration: Debug explicitly builds in Debug mode
  • config.framework: net10.0 targets specific framework for both build and run
  • Omitting configuration preserves current behavior (empty string → SDK default)
  • Omitting framework preserves current behavior (auto-detected from project)
  • Both can be specified together
  • Config is unmarshalled into a strongly-typed struct (not raw map access)
  • Unit tests covering configuration override, framework override, combined, and fallback

Defaults when omitted:

  • configuration: empty string (SDK default, typically Debug)
  • framework: not set (auto-detected from project file)

Out of Scope

  • Custom dotnet run arguments — future enhancement
  • Suppressing DOTNET_NOLOGO — low priority
  • Runtime identifier (-r) support — future enhancement

Testing Expectations

  • Unit tests: table-driven tests for config unmarshalling and dotnet CLI argument construction
  • Test that configuration is passed to both Build() and Run() commands
  • Test that framework is passed as --framework flag to Run() command

Related Issues

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions