-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdefault.ps1
More file actions
103 lines (94 loc) · 3.36 KB
/
default.ps1
File metadata and controls
103 lines (94 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Script Properties
Framework "4.5.2"
properties {
$baseDirectory = Resolve-Path .\
$sourceDirectory = "$baseDirectory\src"
$company = "PsakeZero"
$product = "WebApp"
$outputDirectory = "$baseDirectory\artifacts"
$packagesDirectory = "$sourceDirectory\packages"
$packagesOutputDirectory = "$outputDirectory\packages"
$environment = "Local"
# msbuild settings
$solution = "WebApp.sln"
$solutionFile = "$sourceDirectory\$solution"
$verbosity = "normal"
$buildConfiguration = "Release"
$buildPlatform = "Any CPU"
$version = "1.0.0"
$runOctoPack = "false"
# tools
$nugetExe = "$sourceDirectory\.nuget\nuget.exe"
$migrator = "$sourceDirectory\packages\roundhouse.0.8.6\bin\rh.exe"
$sqlPackageExe = "$baseDirectory\tools\SqlPackage.13.0.3450\sqlPackage.exe"
# database
$databaseServer = "localhost\sqlexpress2014"
$integratedSecurity = "Integrated Security=True"
}
# Script Tasks
task Default -depends Clean, Init, Compile
task Clean {
NukeDirectory $outputDirectory\**
@("bin","obj") | ForEach-Object {
NukeDirectory "$sourceDirectory\**\$_\"
}
}
task Init {
Assert(Test-Path $nugetExe) -failureMessage "Nuget command line tool is missing at $nugetExe"
Write-Host "Creating build output directory at $outputDirectory"
CreateDirectory $outputDirectory
}
task Restore-Packages {
Exec { & $nugetExe "restore" $solutionFile }
}
task Clean-Packages {
Remove-Item -Force -Recurse $packagesDirectory;
CreateDirectory $packagesDirectory;
}
task Compile -depends Init, Restore-Packages, New-AssemblyInfo {
Exec {
msbuild $solutionFile `
/verbosity:$verbosity `
/p:Configuration=$buildConfiguration `
/p:Platform=$buildPlatform
}
}
task New-AssemblyInfo {
CreateCommonAssemblyInfo -version $version -buildConfiguration $buildConfiguration -filename "$sourceDirectory\CommonAssemblyInfo.cs"
}
# Script Functions
function CreateDirectory($directory) {
Write-Host "Creating $directory"
New-Item $directory -ItemType Directory -Force | Out-Null
}
function NukeDirectory($directory) {
if(Test-Path $directory){
Write-Host "Removing $directory"
Remove-Item $directory -Force -Recurse | Out-Null
} else {
Write-Host "$directory does not exist"
}
}
function CreateCommonAssemblyInfo($version,$buildConfiguration,$filename) {
$year = (Get-Date).Year
"using System;
using System.Reflection;
using System.Runtime.InteropServices;
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: ComVisibleAttribute(false)]
[assembly: AssemblyVersionAttribute(""$version"")]
[assembly: AssemblyFileVersionAttribute(""$version"")]
[assembly: AssemblyCopyrightAttribute(""Copyright $year"")]
[assembly: AssemblyProductAttribute(""$product"")]
[assembly: AssemblyCompanyAttribute(""$company"")]
[assembly: AssemblyConfigurationAttribute(""$buildConfiguration"")]
[assembly: AssemblyInformationalVersionAttribute(""$version"")]" | out-file -FilePath $filename -encoding "ASCII"
}