diff --git a/MSBuild.NugetContentRestore.Tasks/NugetContentRestoreTask.cs b/MSBuild.NugetContentRestore.Tasks/NugetContentRestoreTask.cs index 9a6cb1f..8b189e7 100755 --- a/MSBuild.NugetContentRestore.Tasks/NugetContentRestoreTask.cs +++ b/MSBuild.NugetContentRestore.Tasks/NugetContentRestoreTask.cs @@ -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 @@ -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; } @@ -53,7 +53,7 @@ public string ConfigFileFullPath { return _configFileFullPath ?? Path.Combine(ProjectDir, "packages.config"); } - set { _configFileFullPath = value; } + set { _configFileFullPath = value; } } #endregion @@ -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(); @@ -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) @@ -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); } }