-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.ps1
54 lines (49 loc) · 2.58 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
properties {
$projectName = "Conditions"
$buildNumber = "1.2.0.1"
$rootDir = Resolve-Path .\
$buildOutputDir = "$rootDir\build"
$srcDir = "$rootDir\src\Conditions"
$solutionFilePath = "$srcDir\$projectName.sln"
}
task default -depends Clean, Compile, TransposeSource, CreateNuGetPackage
task Clean {
Remove-Item $buildOutputDir -Force -Recurse -ErrorAction SilentlyContinue
exec { msbuild /nologo /verbosity:quiet $solutionFilePath /t:Clean }
}
task Compile {
exec { msbuild /nologo /verbosity:quiet $solutionFilePath /p:Configuration=Release }
}
task TransposeSource {
mkdir $buildOutputDir\SampleConsumer
robocopy $rootDir\SampleConsumer $buildOutputDir\SampleConsumer *.* /S
robocopy $srcDir\CuttingEdge.Conditions $buildOutputDir\SampleConsumer\SampleConsumer\content *.cs *.resx /S /XD Properties
[xml]$xml = gc $buildOutputDir\SampleConsumer\SampleConsumer\SampleConsumer.csproj
$itemGroup = $xml.Project.ItemGroup[1]
gci $buildOutputDir\SampleConsumer\SampleConsumer\content -recurse -filter *.cs |% {
"Processing $_"
Replace-Text $_ "namespace CuttingEdge.Conditions" "namespace Conditions"
Replace-Text $_ "using CuttingEdge.Conditions." "using Conditions."
Replace-Text $_ "public static partial class" "internal static partial class"
Replace-Text $_ "public static class" "internal static class"
Replace-Text $_ "public abstract class" "internal abstract class"
Replace-Text $_ "public class" "internal class"
Replace-Text $_ "public enum" "internal enum"
Replace-Text $_ "public interface" "internal interface"
$compile = $xml.CreateElement("Compile", "http://schemas.microsoft.com/developer/msbuild/2003")
$fileRelPath = $_.FullName.Substring("$buildOutputDir\SampleConsumer\SampleConsumer\".Length)
$compile.SetAttribute("Include" , $fileRelPath)
$itemGroup.AppendChild($compile)
}
gci $buildOutputDir\SampleConsumer\SampleConsumer\content -recurse -filter *.resx |% {
$embeddedResource = $xml.CreateElement("EmbeddedResource", "http://schemas.microsoft.com/developer/msbuild/2003")
$embeddedResource.SetAttribute("Include", "content\$_")
$itemGroup.AppendChild($embeddedResource)
}
$xml.Save("$buildOutputDir\SampleConsumer\SampleConsumer\SampleConsumer.csproj")
exec { msbuild /nologo /verbosity:quiet "$buildOutputDir\SampleConsumer\SampleConsumer.sln" /p:Configuration=Release }
}
task CreateNuGetPackage -depends TransposeSource {
copy-item $rootDir\Conditions.Sources.nuspec $buildOutputDir
exec { .$rootDir\tools\nuget.exe pack $buildOutputDir\Conditions.Sources.nuspec -BasePath .\ -o $buildOutputDir -version $buildNumber }
}