-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathPackaging.fsx
43 lines (37 loc) · 1.64 KB
/
Packaging.fsx
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
#r @"../../../packages/FAKE/tools/FakeLib.dll"
#r "System.Xml.Linq.dll"
#r "System.IO.Compression.dll"
#load "./Utils.fsx"
open System
open System.IO
open System.IO.Compression
open System.Text.RegularExpressions
open System.Xml.Linq
open Fake
open Utils
let private getPackageName nupkg =
// Regex turns D:\output\My.Package.1.0.0.0.nupkg into My.Package
let regex = new Regex(".*\\\\([^\\\\]+)\\.[\\d]+\\.[\\d]+\\.[\\d]+[\\.\\-][\\d\\-a-zA-Z]+\\.nupkg")
regex.Replace(nupkg, "$1")
let private pushPackagesToDir (config: Map<string, string>) dir nupkg =
let info = new FileInfo(nupkg)
let name = getPackageName nupkg
let directory = sprintf "%s\%s" dir name
if (not (Directory.Exists(directory))) then
Directory.CreateDirectory(directory) |> ignore
let file = info.CopyTo(sprintf "%s\%s" directory info.Name, true)
sprintf "Pushed File: %s to: %s" info.Name directory |> ignore
let cleanDirOnceHistory = new System.Collections.Generic.List<string>()
let CleanDirOnce dir =
if (cleanDirOnceHistory.Contains(dir)) = false then
cleanDirOnceHistory.Add(dir)
CleanDir dir
let package config _ =
CleanDirOnce (Map.find "packaging:output" config)
Paket.Pack (fun p -> { p with OutputPath = Map.find "packaging:output" config })
let push config _ =
setEnvironVar "nugetkey" (Map.find "packaging:apikey" config)
Paket.Push (fun p -> { p with
PublishUrl = Map.find "packaging:pushurl" config
EndPoint = Map.find "packaging:pushendpoint" config
WorkingDir = Map.find "packaging:output" config })