import path from "path" ; import { State } from "../../state" ; import { Paths } from "../../util" ; import fs from "fs-extra" ; import { buildAsync , buildSync , Command , Definition } from "./definition" ; export const DotnetHandler = ( opts ) => { const dir = State . Function . artifactsPath ( opts . root , path . join ( opts . id , opts . srcPath ) ) ; const target = path . join ( dir , path . basename ( opts . handler ) . split ( ":" ) [ 0 ] + ".dll" ) ; const cmd = { command : "dotnet" , args : [ "publish" , "--output" , dir , "--configuration" , "Release" , "--framework" , "netcoreapp3.1" , "/p:GenerateRuntimeConfigurationFiles=true" , "/clp:ForceConsoleColor" , "--self-contained" , "false" , "-nologo" , "--verbosity" , process . env . DEBUG ? "minimal" : "quiet" , ] , env : { } , } ; return { build : async ( ) => { fs . removeSync ( dir ) ; fs . mkdirpSync ( dir ) ; return buildAsync ( opts , cmd ) ; } , bundle : ( ) => { fs . removeSync ( dir ) ; fs . mkdirpSync ( dir ) ; buildSync ( opts , cmd ) ; return { handler : opts . handler , directory : dir , } ; } , run : { command : "dotnet" , args : [ "exec" , path . join ( Paths . OWN_PATH , "../src/" , "runtime" , "shells" , "dotnet-bootstrap" , "release" , "dotnet-bootstrap.dll" ) , target , opts . handler , ] , env : { } , } , watcher : { include : [ path . join ( opts . srcPath , "**/*.cs" ) , path . join ( opts . srcPath , "**/*.csx" ) , ] , ignore : [ ] , } , } ; } ;