-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
90 lines (73 loc) · 1.91 KB
/
build.cake
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
#addin nuget:?package=cake.iis&version=0.3.0
#addin nuget:?package=cake.hosts&version=1.1.0
#addin nuget:?package=cake.powershell&version=0.4.5
var target = Argument("target", "default");
var rootPath = "./";
var srcPath = rootPath + "1-src/";
var solution = rootPath + "nuget.server.sln";
var website = new {
host = "nuget-server.test",
path = srcPath + "web.nuget.server",
appPoolName = "nuget-server.test"
};
Task("clean")
.Description("清理缓存")
.Does(() =>
{
CleanDirectories("./src/**/bin");
});
Task("restore")
.Description("还原依赖")
.Does(() =>
{
NuGetRestore(solution);
});
Task("build")
.Description("构建项目")
.IsDependentOn("clean")
.IsDependentOn("restore")
.Does(() =>
{
MSBuild(solution, new MSBuildSettings {
Verbosity = Verbosity.Minimal
});
});
Task("deploy")
.Description("部署项目")
.Does(() =>
{
AddHostsRecord("127.0.0.1", website.host);
DeleteSite(website.host);
CreateWebsite(new WebsiteSettings()
{
Name = website.host,
Binding = IISBindings.Http.SetHostName(website.host)
.SetIpAddress("*")
.SetPort(80),
ServerAutoStart = true,
PhysicalDirectory = website.path,
ApplicationPool = new ApplicationPoolSettings()
{
Name = website.appPoolName,
IdentityType = IdentityType.LocalSystem,
MaxProcesses = 1,
ManagedRuntimeVersion = "v4.0"
}
});
});
Task("open-browser")
.Description("打开浏览器")
.Does(() =>
{
StartPowershellScript("Start-Process", args =>
{
args.Append("chrome.exe")
.Append("'-incognito'")
.Append(",'http://" + website.host + "/'");
});
});
Task("default")
.IsDependentOn("build")
.IsDependentOn("deploy")
.IsDependentOn("open-browser");
RunTarget(target);