-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.ps1
118 lines (105 loc) · 4.43 KB
/
default.ps1
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Framework 4.5.1
properties{
$projectName = "FluentDynamoDB"
$config = if($useConfig){$useConfig} else {"Debug"};
$baseDir = Resolve-Path .\
$srcDir = "$baseDir\src"
$buildDir = "$baseDir\build\"
$packagesDir = "$buildDir\$config\"
$slnFile = "$baseDir\FluentDynamoDB.sln"
$buildNbr = if($env:build_number){$env:build_number} else {"999"};
$version = "2.1.0.$buildNbr"
$nunitPath = "$baseDir\packages\NUnit.Runners.2.6.4\tools"
$testDir = "$buildDir\test"
$unitTestAssembly = "$baseDir\test\FluentDynamoDb.Tests\bin\$config\FluentDynamoDb.Tests.dll"
}
task default -depends Test
task CI -depends Test, NuSpecVersion
task Clean {
"#########################################################"
"### Cleaning msbuild ###"
"#########################################################"
exec {
msbuild $slnFile /m /t:Clean /p:VisualStudioVersion=14.0
}
pushd src
dir -directory bin -recurse | remove-item -recurse -force
dir -directory obj -recurse | remove-item -recurse -force
popd
remove-item $packagesDir -recurse -ErrorAction Ignore
}
task CommonAssemblyInfo -description "Builds common assembly info file" {
"#########################################################"
"### Updating CommonAssemblyInfo ###"
"#########################################################"
create-commonAssemblyInfo "$version" $projectName "$srcDir\CommonAssemblyInfo.cs"
}
task NuSpecVersion -description "Updates version number in NuSpec file" {
"#########################################################"
"### Updating NuSpec Versions ###"
"#########################################################"
Get-ChildItem "nuget/" | ForEach-Object {
[xml]$xml = Get-Content $_.FullName
$xml.package.metadata.version = $version
$xml.Save($_.FullName)
}}
task Build -depends Clean,CommonAssemblyInfo -description "Builds solution"{
"#########################################################"
"### Building ###"
"#########################################################"
exec { msbuild $slnFile /m /p:Configuration=$config /t:Build /p:VisualStudioVersion=14.0 }
}
task Test -depends Build -description "Run all tests" {
"#########################################################"
"### Run Tests ###"
"#########################################################"
if (!(Test-Path -Path $buildDir)){
create_directory $buildDir
}
exec {
& $nunitPath\nunit-console.exe $unitTestAssembly /nologo /nodots /xml=$buildDir\UnitTestResult.xml
}
}
function global:create-commonAssemblyInfo($version,$applicationName,$filename)
{
"using System.Reflection;
using System.Runtime.CompilerServices;
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: AssemblyTitle(""FluentDynamoDb"")]
[assembly: AssemblyDescription(""Fluent, POCO friendly, convention-based mappings for DynamoDb. Get your fluent on :-)"")]
[assembly: AssemblyVersionAttribute(""$version"")]
[assembly: AssemblyFileVersionAttribute(""$version"")]
[assembly: AssemblyCopyrightAttribute(""Copyright 2013-2015"")]
[assembly: AssemblyProductAttribute(""$applicationName"")]
[assembly: AssemblyCompanyAttribute("""")]
[assembly: AssemblyConfigurationAttribute(""release"")]
[assembly: AssemblyInformationalVersionAttribute(""$version"")]
[assembly: InternalsVisibleTo(""FluentDynamoDb.Tests"")]" | out-file $filename -encoding "ASCII"
}
function global:Copy_and_flatten ($source,$filter,$dest) {
ls $source -filter $filter -r | Where-Object{!$_.FullName.Contains("$testCopyIgnorePath") -and !$_.FullName.Contains("packages") }| cp -dest $dest -force
}
function global:copy_all_assemblies_for_test($destination){
create_directory $destination
Copy_and_flatten $srcDir *.exe $destination
Copy_and_flatten $srcDir *.dll $destination
Copy_and_flatten $srcDir *.config $destination
Copy_and_flatten $srcDir *.xml $destination
Copy_and_flatten $srcDir *.pdb $destination
Copy_and_flatten $srcDir *.sql $destination
Copy_and_flatten $srcDir *.xlsx $destination
}
function global:create_directory($directory_name)
{
mkdir $directory_name -ErrorAction SilentlyContinue | out-null
}