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