Skip to content
Open
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
28 changes: 17 additions & 11 deletions MSBuild.NugetContentRestore.Tasks/NugetContentRestoreTask.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using System.Collections.Generic;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using MSBuild.NugetContentRestore.Tasks.Entities;
using MSBuild.NugetContentRestore.Tasks.Extensions;
using MSBuild.NugetContentRestore.Tasks.Utilities;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Serialization;

using MSBuild.NugetContentRestore.Tasks.Entities;
using MSBuild.NugetContentRestore.Tasks.Extensions;
using MSBuild.NugetContentRestore.Tasks.Utilities;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace MSBuild.NugetContentRestore.Tasks
{
public class NugetContentRestoreTask : Task
Expand All @@ -32,6 +30,8 @@ public class NugetContentRestoreTask : Task
public string[] AdditionalFolders { get; set; }
public string[] AdditionalIgnoreFilePatterns { get; set; }

public string[] SpecificPackages { get; set; }

[Required]
public string SolutionDir { get; set; }

Expand All @@ -53,7 +53,7 @@ public string ConfigFileFullPath
{
return _configFileFullPath ?? Path.Combine(ProjectDir, "packages.config");
}
set { _configFileFullPath = value; }
set { _configFileFullPath = value; }
}

#endregion
Expand All @@ -70,6 +70,7 @@ public override bool Execute()
Log.LogMessage(MessageImportance.Low, "NugetContentRestore :: ProjectDir='{0}'", ProjectDir);
Log.LogMessage(MessageImportance.Low, "NugetContentRestore :: ConfigFileFullPath='{0}'", ConfigFileFullPath);
Log.LogMessage(MessageImportance.Low, "NugetContentRestore :: EnableSmartRestore='{0}'", EnableSmartRestore.ToString());
Log.LogMessage(MessageImportance.Low, "NugetContentRestore :: SpecificPackages='{0}'", SpecificPackages);

// Get NuGet Package Configuration
var packages = GetPackages();
Expand All @@ -83,6 +84,11 @@ public override bool Execute()
Log.LogMessage(MessageImportance.Low, "NugetContentRestore :: {0} :: ContentsFullPath='{1}'", package.FolderName, packageContentsFullPath);
if (!Directory.Exists(packageContentsFullPath)) continue;

if (SpecificPackages != null)
{
if (!SpecificPackages.Contains(package.Name)) continue;
}

// Create Regex List for Ignore File Patterns
var ignoreFilePatternsArray = _ignoreFilePatterns;
if (AdditionalIgnoreFilePatterns != null)
Expand All @@ -103,13 +109,13 @@ public override bool Execute()
}

// Restore Package Content for additional folders (AdditionalFolder)
if (AdditionalFolders == null) continue;
if (AdditionalFolders == null || AdditionalFolders.Count() == 0) continue;
foreach (var folder in AdditionalFolders)
{
var sourceFolderInfo = new DirectoryInfo(Path.Combine(packageContentsFullPath, folder));
if (!sourceFolderInfo.Exists) continue;

Log.LogMessage(MessageImportance.High, "NugetContentRestore :: {0} :: {1} :: Restoring content files", package.FolderName, folder);
Log.LogMessage(MessageImportance.High, "NugetContentRestore :: {0} :: {1} :: Restoring content files", package.FolderName, folder);
sourceFolderInfo.CopyTo(Path.Combine(ProjectDir, folder), true, filePatterns.ToArray(), EnableSmartRestore);
}
}
Expand Down