public void AssembliesUpdated(IEnumerable <Exports.IAssembly> assemblyPaths) { var items = new List <ITaskItem>(); var excludedAssemblies = ExcludeAssemblies != null?ExcludeAssemblies.Select(x => x.ItemSpec).ToList() : new List <string>(0); var assemblies = assemblyPaths.Distinct(new PathComparer()).ToList(); foreach (var assemblyRef in assemblies) { if (excludedAssemblies.Contains(assemblyRef.AssemblyName.Name, StringComparer.OrdinalIgnoreCase)) { Log.LogMessage("Ignoring OpenWrap reference to '{0}'", assemblyRef.File.Path.FullPath); continue; } if (InputReferences.Any(x => string.Equals(x.ItemSpec, assemblyRef.AssemblyName.Name, StringComparison.OrdinalIgnoreCase))) { Log.LogMessage("OpenWrap reference to '{0}' already added", assemblyRef.File.Path.FullPath); continue; } Log.LogMessage("Adding OpenWrap reference to '{0}'", assemblyRef.File.Path.FullPath); var item = new TaskItem(assemblyRef.AssemblyName.FullName); item.SetMetadata("HintPath", assemblyRef.File.Path.FullPath); item.SetMetadata("Private", CopyLocal ? "True" : "False"); item.SetMetadata("FromOpenWrap", "True"); items.Add(item); } OutputReferences = items.ToArray(); }
/// <summary> /// 獲取指定目錄下所有文件的列表信息 /// </summary> /// <param name="path">指定目錄</param> /// <param name="fileList">文件列表信息</param> private void GetDirectoryFiles(string path, List <FileInfo> fileList) { DirectoryInfo folder = new DirectoryInfo(path); // 遍歷文件 foreach (var fi in from _ in folder.GetFiles(SearchKeyword) where !ExcludeAssemblies.Contains(_.Name) orderby _.Name.Length descending select _) { fileList.Add(fi); } // 遍歷文件夾 folder.GetDirectories().ToList().ForEach(d => GetDirectoryFiles(d.FullName, fileList)); }