-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.cake
More file actions
181 lines (155 loc) · 5.59 KB
/
Copy pathbuild.cake
File metadata and controls
181 lines (155 loc) · 5.59 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#addin nuget:?package=Cake.Git&version=1.0.1
#tool "nuget:?package=nuget.commandline&version=5.9.1"
var target = Argument("target", "Default");
var configuration = Argument("Configuration", "Release");
//*****************************************************************************
// Constants
string artefacts = "./Artifacts";
// ****************************************************************************
void UpdateSettings(DotNetCoreSettings settings)
{
if (settings.EnvironmentVariables == null)
{
settings.EnvironmentVariables = new Dictionary<string, string>();
}
var branch = GitBranchCurrent("..");
//settings.EnvironmentVariables.Add("RepositoryBranch", branch.FriendlyName);
settings.EnvironmentVariables.Add("RepositoryCommit", branch.Tip.Sha);
}
var netCoreBuildSettings = new DotNetCoreBuildSettings()
{
Configuration = configuration,
NoDependencies = false,
NoIncremental = true,
NoRestore = false
};
var netCoreDotNetCorePackSettings = new DotNetCorePackSettings()
{
Configuration = configuration,
OutputDirectory = artefacts,
IncludeSource = false,
IncludeSymbols = false,
NoBuild = false
};
string[] testProjectNetStandrd = new string[]
{
"../src/Test/MassiveDynamicProxyGenerator.Tests.NetStandard/MassiveDynamicProxyGenerator.Tests.NetStandard.csproj",
"../src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests.NetCore/MassiveDynamicProxyGenerator.SimpleInjector.Tests.NetCore.csproj",
"../src/Test/MassiveDynamicProxyGenerator.DependencyInjection.Test/MassiveDynamicProxyGenerator.DependencyInjection.Test.csproj"
};
string[] testProjectNetFull = new string[]
{
"../src/Test/MassiveDynamicProxyGenerator.SimpleInjector.Tests/MassiveDynamicProxyGenerator.SimpleInjector.Tests.csproj",
"../src/Test/MassiveDynamicProxyGenerator.Tests/MassiveDynamicProxyGenerator.Tests.csproj",
};
// ****************************************************************************
// Tasks
Task("Clean")
.Does(()=>
{
foreach(var projFile in GetFiles("../src/Src/*/*.csproj"))
{
var projDirectory = projFile.GetDirectory();
Information($"Clear {projDirectory}");
CleanDirectory(projDirectory + Directory("/obj"));
CleanDirectory(projDirectory + Directory("/bin"));
}
foreach(var projFile in GetFiles("../src/Test/*/*.csproj"))
{
var projDirectory = projFile.GetDirectory();
Information($"Clear {projDirectory}");
CleanDirectory(projDirectory + Directory("/obj"));
CleanDirectory(projDirectory + Directory("/bin"));
}
CleanDirectory(artefacts);
});
Task("Build")
.IsDependentOn("Clean")
.Does(()=>
{
foreach(var projFile in GetFiles("../src/Src/*/*.csproj"))
{
DotNetCoreBuild(projFile.ToString(), netCoreBuildSettings);
}
});
Task("BuildNetCoreTests")
.IsDependentOn("Build")
.Does(()=>
{
foreach(string projFile in testProjectNetStandrd)
{
DotNetCoreBuild(projFile, netCoreBuildSettings);
}
});
Task("RestoreNetFullNugets")
.IsDependentOn("Clean")
.Does(()=>
{
NuGetRestore("../src/MassiveDynamicProxyGenerator.sln");
});
Task("BuildNetFullTests")
.IsDependentOn("Build")
.IsDependentOn("RestoreNetFullNugets")
.Does(()=>
{
foreach(var projFile in testProjectNetFull)
{
MSBuild(projFile, settings =>
settings.SetConfiguration(configuration));
}
});
Task("TestNetStandard")
.IsDependentOn("Build")
.IsDependentOn("BuildNetCoreTests")
.Does(()=>
{
foreach(string projFile in testProjectNetStandrd)
{
string fileName = System.IO.Path.GetFileNameWithoutExtension(projFile);
var netCoreDotNetCoreTestSettings = new DotNetCoreTestSettings()
{
Configuration = configuration,
ArgumentCustomization = args => args.Append("/p:CollectCoverage=true")
.Append("/p:CoverletOutputFormat=lcov")
.Append("/p:CoverletOutput=../../../BuildScripts/Artifacts/lcov.info")
};
DotNetCoreTest(projFile, netCoreDotNetCoreTestSettings);
}
});
Task("TestNetFull")
.IsDependentOn("Build")
.IsDependentOn("BuildNetFullTests")
.Does(()=>
{
foreach(string projFile in testProjectNetFull)
{
Verbose($"Run tests in {projFile}");
string dllName = System.IO.Path.ChangeExtension(System.IO.Path.GetFileName(projFile), ".dll");
string folder = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(projFile), "bin", configuration);
MSTest(System.IO.Path.Combine(folder, dllName), new MSTestSettings()
{
NoIsolation = false,
WorkingDirectory = folder,
// Fix Cake problem
ToolPath = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\MSTest.exe"
});
}
});
Task("Test")
.IsDependentOn("TestNetStandard")
.IsDependentOn("TestNetFull");
Task("Pack")
.IsDependentOn("Test")
.Does(()=>
{
UpdateSettings(netCoreDotNetCorePackSettings);
foreach(var projFile in GetFiles("../src/Src/*/*.csproj"))
{
DotNetCorePack(projFile.ToString(), netCoreDotNetCorePackSettings);
}
});
Task("Default")
.IsDependentOn("Pack");
//*****************************************************************************
// EXECUTION
RunTarget(target);