-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execute self-contained .NET binary #5519
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. The additional functionality you've added here is basically what we do for Go today:
pulumi/sdk/go/pulumi-language-go/main.go
Lines 45 to 75 in 9ef5c72
func findProgram(binary string) (*exec.Cmd, error) { | |
// we default to execution via `go run` | |
// the user can explicitly opt in to using a binary executable by specifying | |
// runtime.options.binary in the Pulumi.yaml | |
if binary != "" { | |
program, err := executable.FindExecutable(binary) | |
if err != nil { | |
return nil, errors.Wrap(err, "expected to find prebuilt executable") | |
} | |
return exec.Command(program), nil | |
} | |
// Fall back to 'go run' style executions | |
logging.V(5).Infof("No prebuilt executable specified, attempting invocation via 'go run'") | |
program, err := executable.FindExecutable("go") | |
if err != nil { | |
return nil, errors.Wrap(err, "problem executing program (could not run language executor)") | |
} | |
cwd, err := os.Getwd() | |
if err != nil { | |
return nil, errors.Wrap(err, "unable to get current working directory") | |
} | |
goFileSearchPattern := filepath.Join(cwd, "*.go") | |
if matches, err := filepath.Glob(goFileSearchPattern); err != nil || len(matches) == 0 { | |
return nil, errors.Errorf("Failed to find go files for 'go run' matching %s", goFileSearchPattern) | |
} | |
return exec.Command(program, "run", cwd), nil | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me.
90600f9
to
5397b98
Compare
* Execute self-contained .NET binary * Skip dotnet lookup for self-contained binaries
Resolves #5334 (other than a binary CLI option, which will move to a new issue)
When the
binary
option is specified, this PR runs it asdotnet foo.dll
for dll files and directly otherwise.This change looks legit to me but is slightly scary in case I'm missing some other non-dll scenario, so reviews are appreciated.