How to run dotnet run
in development mode?
- Define a CLI parameter for development mode, lets call it
mode
and pass it to dotnet run
as dotnet run --mode dev
. In the absence of --mode
, you could configure the code to run dotnet run
command in production mode. - In your
main
function, extract --mode
value from args
and use it to change behavior based on its value:
[<EntryPoint>]
let main args =
let mode =
args
|> Seq.chunkBySize 2
|> Seq.filter (fun arg -> arg[0] = "--mode")
|> Seq.map (fun args -> args[1])
|> Seq.tryExactlyOne
match mode with
| Some mode when mode = "dev" ->
// dev code
| _ ->
// prod code