-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_make-nuget.ps1
65 lines (50 loc) · 2.82 KB
/
_make-nuget.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
# UPDATE 10/4/18 Just seen that Visual studio now automatically creates the nuget package, I can possibly remove this script.
# Will keep this here until I've time to confirm the package is exactly as we need it
# and that when we use msbuild from command line the nuget package get's created. we might still need this with appveyor.
function MAKE_NUGET($projectPath, $dest) {
# -------------------------------------------------------------------
function Split([string] $src,[string] $seperator) {
$ret = $src.Split(@($seperator), [System.StringSplitOptions]::RemoveEmptyEntries)
(,$ret) # force result to be an array even if there was only 1 string
}
# -------------------------------------------------------------------
function checkBuild() {
$file = get-item $dir\bin\Release\$name.dll
Write-Host "Checking age of $file"
CheckAge $file $minutes "Please make a recent RELEASE build before running this script. It's quite possible the last build you made was DEBUG."
exit 1
}
# -------------------------------------------------------------------
function CheckAge($file, $minutes, $message) {
$age = (get-date).Subtract($file.LastAccessTime).TotalMinutes
$name = $file.Name
if ($age -gt $minutes) {
write-Host ("$name is {0:0} minutes old. exiting script" -f $age)
write-Host $message
exit 1
}
}
# -------------------------------------------------------------------
function MostRecent($wildcard) {
$latest = gci $dir\$wildcar | sort LastWriteTime | select -first 1
CheckAge $latest
}
# ===================================================================
# make-nuget.ps1
# ===================================================================
# AAARGH need simpler names for all this shit!!!
# projectFilePath, projectFileObject, projectFileNameWithExt, projectFileNameOnly
$projectFile = Get-Item $projectPath
$projectName = $projectFile.Name
$name = (Split $projectName ".csproj")
$dir = $projectFile.Directory.FullName
# number of minutes old (age) that I allow the release build to be, before the script will tell me I have forgotten to make a release build, because yknow i forget that me and visualstudio live perpetually in DEBUG mode!
$minutes = 2
Write-Host "Building nuget package : projectPath:$projectPath, projectName:$projectName, name:$name, $dir:dir"
checkBuild
nuget pack $projectPath -Prop Configuration=Release -IncludeReferencedProjects -OutputDirectory $dest
# copy-items MostRecent "*.nupkg" "c:\"
# see https://stackoverflow.com/questions/26111710/nuget-dependencies-not-getting-installed?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
# extra notes on getting the nuget package to automatically include the correct related dependency packages
}
MAKE_NUGET .\Draki.Core\Draki.Core.csproj "C:\src\.nuget\test-packages"