/// <summary> /// Searchs the fol configuration files and nest them. ///From Radim: http://stackoverflow.com/questions/19427333/how-to-find-a-projectitem-by-the-file-name /// </summary> /// <param name="projectItems">The project items.</param> private static void SearchFolConfigFilesAndNestThem(ProjectItems projectItems) { foreach (ProjectItem projectItem in projectItems) { string transFileName; if (projectItem.TryGetPropertyValue(ProjectItemExt.FullPathProperty, out transFileName)) { transFileName = Path.GetFileName(transFileName); string configFileName; if (TransformationProvider.CheckTransformationFileAndGetSourceFileFromIt(transFileName, Options.Options.TransfomationFileNameRegexp, Options.Options.SourceFileRegexpMatchIndex, out configFileName)) { var configItem = DteHelper.FindItemByName(projectItems, configFileName, true); var itemToBeNested = DteHelper.FindItemByName(projectItems, transFileName, true); if (configItem == null || itemToBeNested == null) { continue; } // ReSharper disable once UnusedVariable var pitn = configItem.ProjectItems.AddFromFile(itemToBeNested.GetFullPath()); string itemType; if (itemToBeNested.TryGetPropertyValue(ProjectItemExt.ItemTypeProperty, out itemType)) { pitn.TrySetPropertyValue(ProjectItemExt.ItemTypeProperty, itemType); } } } } }