Skip to content
Newer
Older
100644 99 lines (79 sloc) 3.58 KB
206bac8 @synhershko Nuget packaging stuff
authored Sep 23, 2012
1 properties {
2 $base_dir = resolve-path .
3 $build_dir = "$base_dir\build"
4 $global:configuration = "Release"
5 $env:buildlabel = "0.3"
6 }
7
8 task default -depends DoRelease
9
10 task DoRelease -depends CleanOutputDirectory, `
11 CreateOutputDirectories, `
12 Compile, `
13 CreateNugetPackages {
14 Write-Host "Done"
15 }
16
17 task Clean {
18 Remove-Item -force -recurse $build_dir -ErrorAction SilentlyContinue
19 }
20
21 task Init -depends Clean {
22 New-Item $build_dir -itemType directory -ErrorAction SilentlyContinue | Out-Null
23 New-Item $build_dir\net35 -itemType directory -ErrorAction SilentlyContinue | Out-Null
24 New-Item $build_dir\net40 -itemType directory -ErrorAction SilentlyContinue | Out-Null
25 }
26
27 task Compile -depends Init {
28
29 $v4_net_version = (ls "$env:windir\Microsoft.NET\Framework\v4.0*").Name
30
31 exec { &"C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$sln_file" /p:OutDir="$build_dir\net40\" /p:Configuration=$global:configuration }
32 exec { &"C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$sln_file" /p:OutDir="$build_dir\net35\" /p:ToolsVersion=3.5 /p:Configuration=$global:configuration }
33 }
34
35 task CreateOutputDirectories {
36 New-Item $build_dir -itemType directory -ErrorAction SilentlyContinue | Out-Null
37 New-Item $build_dir\net35 -itemType directory -ErrorAction SilentlyContinue | Out-Null
38 New-Item $build_dir\net40 -itemType directory -ErrorAction SilentlyContinue | Out-Null
39 }
40
41 task CleanOutputDirectory {
42 Remove-Item $build_dir -Recurse -Force -ErrorAction SilentlyContinue
43 }
44
45 task CopyRootFiles {
46 cp $base_dir\license.txt $build_dir\Output\license.txt
47 cp $base_dir\readme.txt $build_dir\Output\readme.txt
48 }
49
50 task CreateNugetPackages -depends Compile {
51
52 Remove-Item $base_dir\*.nupkg
53
54 $nuget_dir = "$build_dir\NuGet_packaging"
55 Remove-Item $nuget_dir -Force -Recurse -ErrorAction SilentlyContinue
56 New-Item $nuget_dir -Type directory | Out-Null
57
58 New-Item $nuget_dir\Spatial4n.Core\lib\net40 -Type directory | Out-Null
59 New-Item $nuget_dir\Spatial4n.Core\lib\net20 -Type directory | Out-Null
60 New-Item $nuget_dir\Spatial4n.Core.NTS\lib\net40 -Type directory | Out-Null
61 New-Item $nuget_dir\Spatial4n.Core.NTS\lib\net20 -Type directory | Out-Null
62 Copy-Item $base_dir\.nuget\Spatial4n.Core.nuspec $nuget_dir\Spatial4n.Core\Spatial4n.Core.nuspec
63 Copy-Item $base_dir\.nuget\Spatial4n.Core.NTS.nuspec $nuget_dir\Spatial4n.Core.NTS\Spatial4n.Core.NTS.nuspec
64
65 @("Spatial4n.Core.???") |% { Copy-Item "$build_dir\net40\$_" $nuget_dir\Spatial4n.Core\lib\net40 }
66 @("Spatial4n.Core.NTS.???") |% { Copy-Item "$build_dir\net40\$_" $nuget_dir\Spatial4n.Core.NTS\lib\net40 }
67
68 @("Spatial4n.Core.???") |% { Copy-Item "$build_dir\net35\$_" $nuget_dir\Spatial4n.Core\lib\net20 }
69 @("Spatial4n.Core.NTS.???") |% { Copy-Item "$build_dir\net35\$_" $nuget_dir\Spatial4n.Core.NTS\lib\net20 }
70
71 $packages = Get-ChildItem $nuget_dir *.nuspec -recurse
72 $packages |% {
73 $nuspec = [xml](Get-Content $_.FullName)
74 $nuspec.package.metadata.version = $env:buildlabel
75 $nuspec | Select-Xml '//dependency' |% {
76 if($_.Node.Id.StartsWith('Spatial4n')){
77 $_.Node.Version = "[$env:buildlabel]"
78 }
79 }
80 $nuspec.Save($_.FullName);
81 &"$base_dir\.nuget\nuget.exe" pack $_.FullName
82 }
83
84 # Upload packages
85 $accessPath = "$base_dir\..\Nuget-Access-Key.txt"
86 if ( (Test-Path $accessPath) ) {
87 $accessKey = Get-Content $accessPath
88 $accessKey = $accessKey.Trim()
89
90 # Push to nuget repository
91 $packages | ForEach-Object {
92 &"$base_dir\.nuget\NuGet.exe" push "$($_.BaseName).$env:buildlabel.nupkg" $accessKey
93 }
94 }
95 else {
96 Write-Host "Nuget-Access-Key.txt does not exit. Cannot publish the nuget package." -ForegroundColor Red
97 }
98 }
Something went wrong with that request. Please try again.