-
Notifications
You must be signed in to change notification settings - Fork 9
/
helpers.cake
37 lines (34 loc) · 2.1 KB
/
helpers.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
List<NuSpecContent> GetContent(IEnumerable<string> frameworks, ProjectCollection projects, Func<SolutionProject, bool> projectFilter = null) {
projectFilter = projectFilter ?? (p => true);
var content = new List<NuSpecContent>();
foreach (var framework in frameworks) {
foreach (var project in projects.SourceProjects.Where(projectFilter)) {
Verbose("Loading package files for " + project.Name);
var match = GetFiles(project.Path.GetDirectory() + "/bin/" + configuration + "/" + framework + "/" + project.Name +".*");
var libFiles = match
.Where(f => f.GetExtension() != ".pdb")
.Where(f => !f.FullPath.Contains("Cake.Core"))
.Where(f => !f.FullPath.Contains("Cake.Common"))
.Select(f => new NuSpecContent { Source = f.FullPath, Target = "lib/" + framework});
content.AddRange(libFiles);
}
}
return content;
}
public class ProjectCollection {
public IEnumerable<SolutionProject> SourceProjects {get;set;}
public IEnumerable<DirectoryPath> SourceProjectPaths {get { return SourceProjects.Select(p => p.Path.GetDirectory()); } }
public IEnumerable<SolutionProject> TestProjects {get;set;}
public IEnumerable<DirectoryPath> TestProjectPaths { get { return TestProjects.Select(p => p.Path.GetDirectory()); } }
public IEnumerable<SolutionProject> AllProjects { get { return SourceProjects.Concat(TestProjects); } }
public IEnumerable<DirectoryPath> AllProjectPaths { get { return AllProjects.Select(p => p.Path.GetDirectory()); } }
}
ProjectCollection GetProjects(FilePath slnPath) {
var solution = ParseSolution(slnPath);
var projects = solution.Projects.Where(p => p.Type != "{2150E333-8FDC-42A3-9474-1A3956D46DE8}");
var testAssemblies = projects.Where(p => p.Name.Contains(".Tests")).Select(p => p.Path.GetDirectory() + "/bin/" + configuration + "/" + p.Name + ".dll");
return new ProjectCollection {
SourceProjects = projects.Where(p => !p.Name.Contains(".Tests")),
TestProjects = projects.Where(p => p.Name.Contains(".Tests"))
};
}