Added support for excludes in project.json files.

This commit is contained in:
David Fowler 2014-03-09 14:01:45 -07:00
parent f01620402a
commit 53e3ea15c9
1 changed files with 14 additions and 9 deletions

View File

@ -225,21 +225,26 @@ functions
const string contentTemplate = @"<Content Include=""{0}"" />"; const string contentTemplate = @"<Content Include=""{0}"" />";
// Build the list of resx files // Build the list of resx files
var resxFileNames = FindFilesOfType(projectDir, "*.resx"); var resxFileNames = Files.Include(Path.Combine(projectDir, "**", "*.resx"));
var resxDesignerFiles = new HashSet<string>(resxFileNames.Select(f => Path.ChangeExtension(f, "Designer.cs")), var resxDesignerFiles = new HashSet<string>(resxFileNames.Select(f => Path.ChangeExtension(f, "Designer.cs")),
StringComparer.OrdinalIgnoreCase); StringComparer.OrdinalIgnoreCase);
var resxFiles var resxFiles
= String.Join(Environment.NewLine, = String.Join(Environment.NewLine,
resxFileNames.Select(p => String.Format(resxTemplate, p, projectName, Path.GetFileNameWithoutExtension(p)))); resxFileNames.Select(p => String.Format(resxTemplate, Path.Combine("..", "..", p), projectName, Path.GetFileNameWithoutExtension(p))));
// Build the list of cs files var sourcePattern = Get<string>(d, "code") ?? @"**\*.cs";
var csFiles var sourceExcludePattern = Get<string>(d, "exclude") ?? "";
= String.Join(Environment.NewLine, var objPath = Path.Combine(projectDir, "obj");
FindFilesOfType(projectDir, "*.cs") var objPattern = Directory.Exists(objPath) ? Path.Combine(objPath, "**", "*.*") : projectDir;
.Select(p => resxDesignerFiles.Contains(p)
? String.Format(resxDesignerTemplate, p, Path.GetFileNameWithoutExtension(p).Replace(".Designer", "")) var csFiles = String.Join(Environment.NewLine, Files.Include(Path.Combine(projectDir, sourcePattern))
: String.Format(csTemplate, p))); .Exclude(Path.Combine(projectDir, sourceExcludePattern))
.Exclude(objPattern)
.Select(p => resxDesignerFiles.Contains(p)
? String.Format(resxDesignerTemplate, Path.Combine("..", "..", p), Path.GetFileNameWithoutExtension(p).Replace(".Designer", ""))
: String.Format(csTemplate, Path.Combine("..", "..", p))));
var contentFileExtensions = new [] { var contentFileExtensions = new [] {
"*.cshtml", "*.cshtml",