Execute self-contained .NET binary (#5519)
* Execute self-contained .NET binary * Skip dotnet lookup for self-contained binaries
This commit is contained in:
parent
2b67c6ea81
commit
879066a60b
|
@ -15,6 +15,9 @@ CHANGELOG
|
||||||
- Add internal scaffolding for using cross-language components from .NET.
|
- Add internal scaffolding for using cross-language components from .NET.
|
||||||
[#5485](https://github.com/pulumi/pulumi/pull/5485)
|
[#5485](https://github.com/pulumi/pulumi/pull/5485)
|
||||||
|
|
||||||
|
- Support self-contained executables as binary option for .NET programs.
|
||||||
|
[#5519](https://github.com/pulumi/pulumi/pull/5519)
|
||||||
|
|
||||||
## 2.11.2 (2020-10-01)
|
## 2.11.2 (2020-10-01)
|
||||||
|
|
||||||
- feat(autoapi): expose EnvVars LocalWorkspaceOption to set in ctor
|
- feat(autoapi): expose EnvVars LocalWorkspaceOption to set in ctor
|
||||||
|
|
|
@ -61,7 +61,13 @@ func main() {
|
||||||
logging.InitLogging(false, 0, false)
|
logging.InitLogging(false, 0, false)
|
||||||
cmdutil.InitTracing("pulumi-language-dotnet", "pulumi-language-dotnet", tracing)
|
cmdutil.InitTracing("pulumi-language-dotnet", "pulumi-language-dotnet", tracing)
|
||||||
var dotnetExec string
|
var dotnetExec string
|
||||||
if givenExecutor == "" {
|
switch {
|
||||||
|
case givenExecutor != "":
|
||||||
|
logging.V(3).Infof("language host asked to use specific executor: `%s`", givenExecutor)
|
||||||
|
dotnetExec = givenExecutor
|
||||||
|
case binary != "" && !strings.HasSuffix(binary, ".dll"):
|
||||||
|
logging.V(3).Info("language host requires no .NET SDK for a self-contained binary")
|
||||||
|
default:
|
||||||
pathExec, err := exec.LookPath("dotnet")
|
pathExec, err := exec.LookPath("dotnet")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, "could not find `dotnet` on the $PATH")
|
err = errors.Wrap(err, "could not find `dotnet` on the $PATH")
|
||||||
|
@ -70,9 +76,6 @@ func main() {
|
||||||
|
|
||||||
logging.V(3).Infof("language host identified executor from path: `%s`", pathExec)
|
logging.V(3).Infof("language host identified executor from path: `%s`", pathExec)
|
||||||
dotnetExec = pathExec
|
dotnetExec = pathExec
|
||||||
} else {
|
|
||||||
logging.V(3).Infof("language host asked to use specific executor: `%s`", givenExecutor)
|
|
||||||
dotnetExec = givenExecutor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Optionally pluck out the engine so we can do logging, etc.
|
// Optionally pluck out the engine so we can do logging, etc.
|
||||||
|
@ -477,11 +480,18 @@ func (host *dotnetLanguageHost) Run(ctx context.Context, req *pulumirpc.RunReque
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executable := host.exec
|
||||||
args := []string{}
|
args := []string{}
|
||||||
|
|
||||||
if host.binary != "" {
|
switch {
|
||||||
|
case host.binary != "" && strings.HasSuffix(host.binary, ".dll"):
|
||||||
|
// Portable pre-compiled dll: run `dotnet <name>.dll`
|
||||||
args = append(args, host.binary)
|
args = append(args, host.binary)
|
||||||
} else {
|
case host.binary != "":
|
||||||
|
// Self-contained executable: run it directly.
|
||||||
|
executable = host.binary
|
||||||
|
default:
|
||||||
|
// Run from source.
|
||||||
args = append(args, "run")
|
args = append(args, "run")
|
||||||
|
|
||||||
if req.GetProgram() != "" {
|
if req.GetProgram() != "" {
|
||||||
|
@ -496,7 +506,7 @@ func (host *dotnetLanguageHost) Run(ctx context.Context, req *pulumirpc.RunReque
|
||||||
|
|
||||||
// Now simply spawn a process to execute the requested program, wiring up stdout/stderr directly.
|
// Now simply spawn a process to execute the requested program, wiring up stdout/stderr directly.
|
||||||
var errResult string
|
var errResult string
|
||||||
cmd := exec.Command(host.exec, args...) // nolint: gas // intentionally running dynamic program name.
|
cmd := exec.Command(executable, args...) // nolint: gas // intentionally running dynamic program name.
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
cmd.Env = host.constructEnv(req, config)
|
cmd.Env = host.constructEnv(req, config)
|
||||||
|
|
Loading…
Reference in a new issue