Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/vpk/Velopack.Packaging/PackageBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using System.Security;
using System.IO;
using System.Security;
using System.Text.RegularExpressions;

using Markdig;

using Microsoft.Extensions.Logging;

using NuGet.Versioning;

using Velopack.Compression;
using Velopack.Core;
using Velopack.Core.Abstractions;
Expand All @@ -29,7 +34,7 @@ public abstract class PackageBuilder<T> : ICommand<T>

protected Dictionary<string, string> ExtraNuspecMetadata { get; } = new();

private readonly Regex REGEX_EXCLUDES = new(@".*[\\\/]createdump.*|.*\.vshost\..*|.*\.nupkg$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private readonly Regex REGEX_EXCLUDES = new(@".*[\\\/]createdump.*|.*\.vshost\..*|.*\.nupkg$|.*\.pdb", RegexOptions.IgnoreCase | RegexOptions.Compiled);

public PackageBuilder(RuntimeOs supportedOs, ILogger logger, IFancyConsole console)
{
Expand Down Expand Up @@ -325,9 +330,16 @@ void CopyFilesInternal(DirectoryInfo source, DirectoryInfo target)
var path = Path.Combine(target.FullName, fileInfo.Name);
currentFile++;
progress((int) ((double) currentFile / numFiles * 100));
if (excludeAnnoyances && (REGEX_EXCLUDES.IsMatch(path) || manualExclude?.IsMatch(path) == true)) {
Log.Debug("Skipping because matched exclude pattern: " + path);
continue;
if (excludeAnnoyances) {
if (manualExclude != null) {
if (manualExclude.IsMatch(path)) {
Log.Debug("Skipping because matched exclude pattern: " + path);
continue;
}
} else if (REGEX_EXCLUDES.IsMatch(path)) {
Log.Debug("Skipping because matched exclude pattern: " + path);
continue;
}
}

fileInfo.CopyTo(path, true);
Expand All @@ -349,7 +361,12 @@ void CopyFilesInternal(DirectoryInfo source, DirectoryInfo target)

if (excludeAnnoyances) {
foreach (var f in target.EnumerateFiles("*", SearchOption.AllDirectories)) {
if (excludeAnnoyances && (REGEX_EXCLUDES.IsMatch(f.FullName) || manualExclude?.IsMatch(f.FullName) == true)) {
if (manualExclude != null) {
if (manualExclude.IsMatch(f.FullName)) {
Log.Debug("Deleting because matched exclude pattern: " + f.FullName);
f.Delete();
}
} else if (REGEX_EXCLUDES.IsMatch(f.FullName)) {
Log.Debug("Deleting because matched exclude pattern: " + f.FullName);
f.Delete();
}
Expand Down
3 changes: 1 addition & 2 deletions src/vpk/Velopack.Vpk/Commands/Packaging/PackCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public PackCommand(string name, string description, RuntimeOs targetOs = Runtime

ExcludeOption = AddOption<string>((v) => Exclude = v, "--exclude")
.SetDescription("A regex which excludes matched files from the package.")
.SetArgumentHelpName("REGEX")
.SetDefault(@".*\.pdb");
.SetArgumentHelpName("REGEX");

NoPortableOption = AddOption<bool>((v) => NoPortable = v, "--noPortable")
.SetDescription("Skip generating a portable bundle.")
Expand Down