Skip to content
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

Merged
merged 3 commits into from
Oct 7, 2020

Conversation

mikhailshilkov
Copy link
Member

@mikhailshilkov mikhailshilkov commented Oct 6, 2020

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 as dotnet 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.

Copy link
Contributor

@EvanBoyle EvanBoyle left a 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:

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
}

Copy link
Member

@justinvp justinvp left a 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.

@mikhailshilkov mikhailshilkov force-pushed the mikhailshilkov/dotnet-binary-exe branch from 90600f9 to 5397b98 Compare October 7, 2020 07:29
@mikhailshilkov mikhailshilkov merged commit 879066a into master Oct 7, 2020
@pulumi-bot pulumi-bot deleted the mikhailshilkov/dotnet-binary-exe branch October 7, 2020 09:46
abhinav pushed a commit to pulumi/pulumi-dotnet that referenced this pull request Jan 11, 2023
* Execute self-contained .NET binary
* Skip dotnet lookup for self-contained binaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dotnet binary option for self-contained executables
4 participants