forked from dotless/dotless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
psake_ext.ps1
98 lines (90 loc) · 2.68 KB
/
psake_ext.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
# This script was derived from the Rhino.Mocks buildscript written by Ayende Rahien.
function Get-Git-Commit
{
$v = git describe
trap [Exception]
{
$currentDir = pwd
throw "Error: Could not execute git-describe in folder $currentDir. Please make sure that git is installed in your PATH"
}
return $v
}
function Get-Git-Version
{
$v = git describe --abbrev=0
trap [Exception]
{
$currentDir = pwd
throw "Error: Could not execute git-describe in folder $currentDir. Please make sure that git is installed in your PATH"
}
return $v -replace "v", ""
}
function Generate-Assembly-Info
{
param(
[string]$clsCompliant = "true",
[string]$title,
[string]$description,
[string]$company,
[string]$product,
[string]$copyright,
[string]$version,
[string]$file = $(throw "file is a required parameter."),
[bool]$partial = $false
)
$commit = Get-Git-Commit
$asmInfo = "using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
[assembly: ComVisibleAttribute(false)]
[assembly: AssemblyTitleAttribute(""$title"")]
[assembly: AssemblyDescriptionAttribute(""$description"")]
[assembly: AssemblyCompanyAttribute(""$company"")]
[assembly: AssemblyProductAttribute(""$product $commit"")]
[assembly: AssemblyCopyrightAttribute(""$copyright"")]
[assembly: AssemblyVersionAttribute(""$version"")]
[assembly: AssemblyInformationalVersionAttribute(""$version"")]
[assembly: AssemblyFileVersionAttribute(""$version"")]
[assembly: AssemblyDelaySignAttribute(false)]
"
if($partial) {
$asmInfo = $asmInfo + "[assembly: AllowPartiallyTrustedCallers]"
}
$dir = [System.IO.Path]::GetDirectoryName($file)
if ([System.IO.Directory]::Exists($dir) -eq $false)
{
Write-Host "Creating directory $dir"
[System.IO.Directory]::CreateDirectory($dir)
}
Write-Host "Generating assembly info file: $file"
out-file -filePath $file -encoding UTF8 -inputObject $asmInfo
}
function Generate-NuGet
{
param(
[string]$id,
[string]$version,
[string]$authors,
[string]$description,
[string]$file = $(throw "file is a required parameter.")
)
$nugetSpec = "<?xml version=`"1.0`" encoding=`"utf-8`"?>
<package>
<metadata>
<id>$id</id>
<version>$version</version>
<authors>$authors</authors>
<description>$description</description>
<language>en-US</language>
</metadata>
</package>"
$dir = [System.IO.Path]::GetDirectoryName($file)
if ([System.IO.Directory]::Exists($dir) -eq $false)
{
Write-Host "Creating directory $dir"
[System.IO.Directory]::CreateDirectory($dir)
}
Write-Host "Generating NuGet Spec file: $file"
out-file -filePath $file -encoding UTF8 -inputObject $nugetSpec
}