Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- . .\go-helpers
- $arguments = $args
- $default_launch_profile = "Development"
- function clean {
- info "Cleaning build artifacts"
- exec {dotnet clean src -v minimal /nologo}
- }
- function build {
- info "Building solution"
- exec {dotnet build src /nologo}
- }
- function rebuild {
- clean
- build
- }
- function run {
- $project = $arguments[1]
- $parameter = argrest $arguments 2
- if (!$project) {
- error "You must specify which project to run."
- return
- }
- info "Running project '$project' with additional parameters '$parameter'"
- exec {dotnet run --project "src/$project" --launch-profile "$default_launch_profile" "$parameter"}
- }
- function run-async {
- run-self-async "run" (argrest $arguments 1)
- }
- function run-all {
- build
- run-self-async "run" "BotsPotsChef" "--no-build" "--no-restore"
- run-self-async "run" "BotsPotsKonzola" "--no-build" "--no-restore"
- run-self-async "run" "VirtualRobot" "--no-build" "--no-restore"
- }
- function watch {
- $project = $arguments[1]
- $parameter = argrest $arguments 2
- if (!$project) {
- error "You must specify which project to run and watch."
- return
- }
- info "Running and watching project '$project' with additional parameters '$parameter'"
- exec {dotnet watch --project src/$project run --launch-profile "$default_launch_profile" "$parameter"}
- }
- function watch-async {
- run-self-async "watch" (argrest $arguments 1)
- }
- function mig {
- $sub_command = $arguments[1]
- function drop {
- info "Dropping database"
- execute
- }
- function rerun {
- info "Recreating database and running database migrations"
- execute
- }
- function run {
- info "Running database migrations"
- execute
- }
- function rollback {
- info "Rolling back database migrations"
- execute
- }
- function execute {
- $parameter = argrest $arguments 2
- exec {dotnet run --project src/DatabaseMigrations --launch-profile "$default_launch_profile" -- $sub_command "$parameter"}
- }
- function add {
- $now = [System.DateTime]::UtcNow;
- $migration_name = argrest $arguments 2
- if ($migration_name -match " ") {
- $migration_name = (Get-Culture).TextInfo.ToTitleCase($migration_name).Replace(" ", "")
- }
- $migration_filename = $now.ToString("yyyy.MM.dd_HH.mm")
- $migration_file_path = "src/DatabaseMigrations/Migrations/${migration_filename}_$migration_name.cs"
- if ([System.IO.File]::Exists($migration_file_path)) {
- error "Migration file '$migration_file_path' already exists"
- } else {
- $template_substitutions = @{
- MigrationName = $migration_name
- MigrationVersion = $now.ToString("yyyy_MM_dd, HH_mm, ss_fff")
- }
- generate-from-template "src/Migration.cs.template" $migration_file_path $template_substitutions
- info @"
- Successfully added new migration at '$migration_file_path'.
- By default, newly added migration is configured to automatically try to provide migration rollback logic.
- If you want to create a forward-only migration, change the migration base class from AutoReversingMigration to ForwardOnlyMigration.
- If you want to manually provide rollback logic, change the base class to Migration and override the Down method.
- "@
- }
- }
- &$sub_command
- }
- function publish {
- info "Deleting 'publish' folder"
- remove-folder "./publish"
- info "Publishing to 'publish' folder"
- exec {dotnet publish src/BotsPotsChef -c Release -f net461 --self-contained true -o ./publish/BotsPotsChef /nologo}
- exec {dotnet publish src/BotsPotsKonzola -c Release -f net461 --self-contained true -o ./publish/BotsPotsKonzola /nologo}
- info "Packaging BotsBotsChef web application to zip file"
- Compress-Archive -Path ./publish/BotsPotsChef/* -DestinationPath ./publish/BotsPotsChef_Publish
- }
- function go {
- rebuild
- migrate
- }
- main {
- $command = $arguments[0]
- if ($command) {
- &$command
- } else {
- info @"
- Available commands:
- go
- clean
- build
- rebuild
- run
- run-async
- run-all
- watch
- watch-async
- mig run
- mig rerun
- mig rollback
- mig drop
- mig add
- publish
- "@
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement