Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion sdkbuild/dotnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type BuildDotNetProgramOptions struct {
// Required csproj content. This should not contain a dependency on Temporalio
// because this adds a package/project reference near the end.
CsprojContents string
// Optional build configuration (e.g., "Release", "Debug"). If empty,
// uses the .NET default (Debug).
Configuration string
// If present, custom writers that will capture stdout/stderr.
Stdout io.Writer
Stderr io.Writer
Expand All @@ -48,6 +51,8 @@ func BuildDotNetProgram(ctx context.Context, options BuildDotNetProgramOptions)
return nil, fmt.Errorf("program contents required")
} else if options.CsprojContents == "" {
return nil, fmt.Errorf("csproj contents required")
} else if options.Configuration != "" && options.Configuration != "Debug" && options.Configuration != "Release" {
return nil, fmt.Errorf("configuration must be empty, \"Debug\", or \"Release\", got %q", options.Configuration)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if you need to specify, being empty, since the user will always be specifying to see an err message here

}

// Create temp dir if needed that we will remove if creating is unsuccessful
Expand Down Expand Up @@ -80,7 +85,11 @@ func BuildDotNetProgram(ctx context.Context, options BuildDotNetProgramOptions)
return nil, fmt.Errorf("cannot find version path of %v: %w", absCsproj, err)
}
// Need to build this csproj first
cmd := exec.CommandContext(ctx, "dotnet", "build", absCsproj)
csprojArgs := []string{"build", absCsproj}
if options.Configuration != "" {
csprojArgs = append(csprojArgs, "--configuration", options.Configuration)
}
cmd := exec.CommandContext(ctx, "dotnet", csprojArgs...)
cmd.Dir = dir
setupCommandIO(cmd, options.Stdout, options.Stderr)
if err := cmd.Run(); err != nil {
Expand All @@ -103,6 +112,9 @@ func BuildDotNetProgram(ctx context.Context, options BuildDotNetProgramOptions)

// Build it into build folder
cmdArgs := []string{"build", "--output", "build"}
if options.Configuration != "" {
cmdArgs = append(cmdArgs, "--configuration", options.Configuration)
}
if versionArg != "" {
cmdArgs = append(cmdArgs, versionArg)
}
Expand Down
Loading