Skip to content

Commit 1693222

Browse files
committed
Update publish.csx
1 parent 7b4ed5e commit 1693222

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed

dist/Report.pdf

881 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

publish.csx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using System.IO.Compression;
99
using System.Collections.Generic;
1010
using System.Linq;
1111
using System.Text.RegularExpressions;
12+
using GitignoreParserNet;
1213

1314
// Define source and destination paths
1415
string srcStandalone = @".\src\ReadieFur.SourceAnalyzer.Standalone\bin\Debug\net472";
@@ -70,31 +71,28 @@ void CopyFiles(string sourceDir, string destDir)
7071

7172
void ArchiveFiles()
7273
{
73-
// Ignore.Ignore ignore = new();
74-
75-
// IEnumerable<string> gitignoreContents = File.ReadAllText(".gitignore")
76-
// .Split('\n')
77-
// .Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith("#") && line != "[Bb]in/"); //Force inclusion of build output files for this use case.
78-
79-
// //Perfect that this isn't working :3.
80-
// ignore.Add(gitignoreContents);
81-
82-
// IEnumerable<string> files = Directory.EnumerateFiles(srcDir, "*", SearchOption.AllDirectories)
83-
// // .Select(file => (Environment.CurrentDirectory + file.Substring(1)).Replace('\\', '/'));
84-
// .Select(file => file.Substring(2).Replace('\\', '/'));
85-
// IEnumerable<string> filesToArchive = ignore.Filter(files);
86-
87-
// using (ZipArchive archive = ZipFile.Open(srcZipPath, ZipArchiveMode.Create))
88-
// {
89-
// foreach (string file in filesToArchive)
90-
// {
91-
// string relativePath = Path.GetRelativePath(srcDir, file);
92-
// archive.CreateEntryFromFile(file, relativePath);
93-
// }
94-
// }
74+
string[] excludeOverrides = { "[Bb]in/", "[Rr]elease/", "[Dd]ebug/" };
75+
string[] additionalExcludes = { "TestResults/" };
9576

9677
IEnumerable<string> gitignoreContents = File.ReadAllText(".gitignore")
9778
.Split('\n')
98-
.Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith("#") && line != "[Bb]in/"); //Force inclusion of build output files for this use case.
99-
GitignoreParser.Parse(string.Join('\n', gitignoreContents), srcDir, srcZipPath);
79+
.Where(line =>
80+
(!string.IsNullOrWhiteSpace(line)
81+
&& !line.StartsWith("#")
82+
&& !excludeOverrides.Any(line.Contains))
83+
|| additionalExcludes.Any(line.Contains));
84+
85+
GitignoreParser parser = new(string.Join('\n', gitignoreContents));
86+
87+
IEnumerable<string> archiveFiles = Directory.EnumerateFiles(srcDir, "*", SearchOption.AllDirectories)
88+
.Where(file => parser.Accepts(file));
89+
90+
using (ZipArchive archive = ZipFile.Open(srcZipPath, ZipArchiveMode.Create))
91+
{
92+
foreach (string file in archiveFiles)
93+
{
94+
string relativePath = Path.GetRelativePath(srcDir, file);
95+
archive.CreateEntryFromFile(file, relativePath);
96+
}
97+
}
10098
}

0 commit comments

Comments
 (0)