forked from iron-io/functions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotnet.go
44 lines (37 loc) · 869 Bytes
/
dotnet.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package langs
import (
"fmt"
"os"
"os/exec"
)
type DotNetLangHelper struct {
BaseHelper
}
func (lh *DotNetLangHelper) Entrypoint() string {
return "dotnet dotnet.dll"
}
func (lh *DotNetLangHelper) HasPreBuild() bool {
return true
}
// PreBuild for Go builds the binary so the final image can be as small as possible
func (lh *DotNetLangHelper) PreBuild() error {
wd, err := os.Getwd()
if err != nil {
return err
}
cmd := exec.Command(
"docker", "run",
"--rm", "-v",
wd+":/dotnet", "-w", "/dotnet", "microsoft/dotnet:1.0.1-sdk-projectjson",
"/bin/sh", "-c", "dotnet restore && dotnet publish -c release -b /tmp -o .",
)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
if err := cmd.Run(); err != nil {
return fmt.Errorf("error running docker build: %v", err)
}
return nil
}
func (lh *DotNetLangHelper) AfterBuild() error {
return nil
}