public static bool IsUnitTestProject(Project project)
        {
            string projectTypeGuids = GetProjectTypeGuids(project);

            if (string.IsNullOrEmpty(projectTypeGuids))
            {
                return(false);
            }

            projectTypeGuids = StringFormatting.RemoveBracesToUpper(projectTypeGuids);
            string[] guids = projectTypeGuids.Split(';');

            return(guids.Contains(ExtensionConstants.UnitTestProjectType.ToString(), StringComparer.InvariantCultureIgnoreCase));
        }
Пример #2
0
        private static bool RemoveDeletedItems(string extractedFolder, ProjectItems projectItems, string projectFolder)
        {
            var itemChanged = false;

            //Handle file & folder deletes
            foreach (ProjectItem projectItem in projectItems)
            {
                var name = projectItem.FileNames[0];
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                if (StringFormatting.RemoveBracesToUpper(projectItem.Kind) == VSConstants.GUID_ItemType_PhysicalFile.ToString())
                {
                    name = Path.GetFileName(name);
                    // Do not delete the mapping file
                    if (name == ExtensionConstants.SolutionPackagerMapFile)
                    {
                        continue;
                    }
                    // Do not delete the config file
                    if (name == ExtensionConstants.SpklConfigFile)
                    {
                        continue;
                    }
                    if (File.Exists(Path.Combine(extractedFolder, name)))
                    {
                        continue;
                    }

                    projectItem.Delete();
                    itemChanged = true;
                }

                if (StringFormatting.RemoveBracesToUpper(projectItem.Kind) == VSConstants.GUID_ItemType_PhysicalFolder.ToString())
                {
                    name = new DirectoryInfo(name).Name;
                    if (name == projectFolder || name.Equals(D365DeveloperExtensions.Core.Resources.Resource.Constant_PropertiesFolder,
                                                             StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    if (!Directory.Exists(Path.Combine(extractedFolder, name)))
                    {
                        projectItem.Delete();
                        itemChanged = true;
                    }
                    else
                    {
                        if (projectItem.ProjectItems.Count <= 0)
                        {
                            continue;
                        }

                        var subItemChanged = RemoveDeletedItems(Path.Combine(extractedFolder, name),
                                                                projectItem.ProjectItems, projectFolder);
                        if (subItemChanged)
                        {
                            itemChanged = true;
                        }
                    }
                }
            }

            return(itemChanged);
        }