tasks/building.tasks.ps1

# Synopsis: Clean .NET solution
task CleanSolution -If {$CleanBuild} {
    exec { 
        dotnet clean $SolutionToBuild `
                     --configuration $Configuration `
                     --verbosity $LogLevel
    }
}

# Synopsis: Build .NET solution
task BuildSolution GitVersion,RestorePackages,CleanSolution,{
    exec { 
        dotnet build $SolutionToBuild `
                     --no-restore `
                     --configuration $Configuration `
                     /p:Version="$(($script:GitVersion).SemVer)" `
                     /p:EndjinRepositoryUrl="$BuildRepositoryUri" `
                     --verbosity $LogLevel
    }
}

task RestorePackages {
    exec { 
        dotnet restore $SolutionToBuild `
                       --verbosity $LogLevel
    }
}

# Synopsis: Build .NET solution packages
task BuildSolutionPackages GitVersion,{
    exec { 
        dotnet pack $SolutionToBuild `
                    --configuration $Configuration `
                    --no-build `
                    --no-restore `
                    --output $PackagesDir `
                    /p:EndjinRepositoryUrl="$BuildRepositoryUri" `
                    /p:PackageVersion="$(($script:GitVersion).SemVer)" `
                    --verbosity $LogLevel
    }
}