From c85229c0e92fd4d5e196ada7ec09bb114e7a2d21 Mon Sep 17 00:00:00 2001 From: Abdul Mounem Alhamwi Date: Wed, 29 Apr 2020 00:32:04 +0400 Subject: [PATCH] fixed issue #365, enhanced the finding web resource from the local file --- .gitignore | 1 + spkl/SparkleXrm.Tasks/DirectoryInfoEx.cs | 5 ++++- .../Tasks/DownloadWebresourceConfigTask.cs | 14 +++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 401ae9a6..27339e77 100644 --- a/.gitignore +++ b/.gitignore @@ -139,3 +139,4 @@ UpgradeLog*.XML *.ide-shm *.ide-wal /.vs +/spkl/.vs/spkl/config/applicationhost.config diff --git a/spkl/SparkleXrm.Tasks/DirectoryInfoEx.cs b/spkl/SparkleXrm.Tasks/DirectoryInfoEx.cs index ce01b57b..9ffd43a1 100644 --- a/spkl/SparkleXrm.Tasks/DirectoryInfoEx.cs +++ b/spkl/SparkleXrm.Tasks/DirectoryInfoEx.cs @@ -45,7 +45,10 @@ public List Search(string path, string search) } else { - matcher.AddInclude("**\\" + search); + foreach (var item in search.Split('|')) + { + matcher.AddInclude("**/" + item); + } } var globbMatch = matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(path))); diff --git a/spkl/SparkleXrm.Tasks/Tasks/DownloadWebresourceConfigTask.cs b/spkl/SparkleXrm.Tasks/Tasks/DownloadWebresourceConfigTask.cs index 9f1b8ca7..3bffb991 100644 --- a/spkl/SparkleXrm.Tasks/Tasks/DownloadWebresourceConfigTask.cs +++ b/spkl/SparkleXrm.Tasks/Tasks/DownloadWebresourceConfigTask.cs @@ -30,7 +30,7 @@ protected override void ExecuteInternal(string filePath, OrganizationServiceCont var configs = ServiceLocator.ConfigFileFactory.FindConfig(filePath); config = configs[0]; } - catch + catch (Exception ex) { config = new ConfigFile() { @@ -76,8 +76,10 @@ protected override void ExecuteInternal(string filePath, OrganizationServiceCont { throw new SparkleTaskException(SparkleTaskException.ExceptionTypes.MISSING_PREFIX, "Please supply the prefix for your webresources e.g. /p:new"); } + // Get a list of all webresources! - var matchList = ServiceLocator.Queries.GetWebresources(ctx).ToDictionary(w => w.Name.ToLower().Replace(Prefix + (Prefix.EndsWith("_") ? "" : "_"), "")); + //.ToLower().Replace(Prefix + (Prefix.EndsWith("_") ? "" : "_"), "") + var matchList = ServiceLocator.Queries.GetWebresources(ctx).ToDictionary(w => w.Name); var webresourceConfig = config.GetWebresourceConfig(this.Profile).FirstOrDefault(); if (webresourceConfig == null) @@ -90,7 +92,8 @@ protected override void ExecuteInternal(string filePath, OrganizationServiceCont var file = filename.Replace("\\", "/").ToLower(); // Find if there are any matches - var match = matchList.Keys.Where(w => file.Contains(w)).FirstOrDefault(); + //The file was name was not matching the capital case + var match = matchList.Keys.Where(w => file.Contains(w.ToLower())).FirstOrDefault(); if (match != null) { @@ -99,14 +102,15 @@ protected override void ExecuteInternal(string filePath, OrganizationServiceCont var webresourcePath = filename.Replace(rootPath, "").TrimStart('\\').TrimStart('/'); // is it already in the config file - var existingMatch = existingWebResources.Keys.Where(w => webresource.Name.Contains(w)).FirstOrDefault(); + //The file was name was not matching the capital case + var existingMatch = existingWebResources.Keys.Where(w => webresource.Name.ToLower().Contains(w)).FirstOrDefault(); if (existingMatch != null) continue; var webresourceFile = new WebResourceFile { uniquename = webresource.Name, - file = webresourcePath, + file = webresourcePath.Replace(rootPath,""), displayname = "" + webresource.DisplayName, description = "" + webresource.Description };