/// <summary>
        /// Validates the expected references to be added by the given package and the actual references being added matches.
        /// </summary>
        /// <param name="packageFullPath"></param>
        /// <param name="solutionPath"></param>
        public bool?Validate(string packageFullPath, VsProjectManager dteHelper)
        {
            ZipPackage zipPackage = new ZipPackage(packageFullPath);

            if (zipPackage.IsSatellitePackage())
            {
                return(null);
            }

            string solutionPath = dteHelper.SolutionPath;

            HasSuceeded = true;

            Dictionary <string, string> referencesInProject = dteHelper.GetReferences();

            string packageId          = zipPackage.Id;
            List <IPackageFile> files = zipPackage.GetLibFiles().ToList();

            if (files == null || files.Count == 0)
            {
                outputBuilder.AppendFormat(" No Lib files are present in the nupkg file.Skipping reference validation.");
                return(null);
            }

            //Get compatible items for the current project.
            //if no compatible items, then check if there are any files with directly under Lib and get them.
            IEnumerable <IPackageFile> compatibleItems;

            VersionUtility.TryGetCompatibleItems(new FrameworkName(dteHelper.GetProjectFramework()), files, out compatibleItems);
            if (compatibleItems == null || compatibleItems.ToList().Count == 0)
            {
                VersionUtility.TryGetCompatibleItems(null, files, out compatibleItems);
            }
            if (compatibleItems == null || compatibleItems.ToList().Count == 0)
            {
                outputBuilder.AppendFormat(" The package doesnt have a Lib folder matching the current project's target framework : {0}", dteHelper.GetProjectFramework());
                return(null);
            }

            //Check that the compatible lib files are added as references.
            foreach (IPackageFile file in compatibleItems)
            {
                if (file.Path.EndsWith(".dll") || file.Path.EndsWith(".exe")) //exclude xml files
                {
                    string referenceName = Path.GetFileNameWithoutExtension((file.Path));
                    if (!referencesInProject.Keys.Contains(referenceName, StringComparer.OrdinalIgnoreCase))
                    {
                        HasSuceeded = false;
                        errorBuilder.AppendFormat("The reference {0} is not added to project as part of installating package {1}.Check the Solution @ {2} for details", referenceName, packageId, solutionPath);
                        errorBuilder.AppendLine();
                    }
                    else
                    {
                        outputBuilder.AppendFormat("Reference Added properly for Lib : {0} !!", file.Path);
                        outputBuilder.AppendLine();
                    }
                }
            }
            return(HasSuceeded);
        }
        public bool?Validate(string packageFullPath, VsProjectManager dteHelper)
        {
            string solutionPath = dteHelper.SolutionPath;

            HasSuceeded = true;

            ZipPackage          zipPackage = new ZipPackage(packageFullPath);
            List <IPackageFile> files      = zipPackage.GetContentFiles().ToList();

            if (files == null || files.Count == 0)
            {
                outputBuilder.AppendFormat(" No content files are present in the nupkg file.Skipping content validation");
                return(null);
            }

            //Get compatible items for the current project.
            //if no compatible items, then check if there are any files with directly under contents and get them.
            IEnumerable <IPackageFile> compatibleItems;

            VersionUtility.TryGetCompatibleItems(new FrameworkName(dteHelper.GetProjectFramework()), files, out compatibleItems);
            if (compatibleItems == null || compatibleItems.ToList().Count == 0)
            {
                VersionUtility.TryGetCompatibleItems(null, files, out compatibleItems);
            }
            if (compatibleItems == null || compatibleItems.ToList().Count == 0)
            {
                outputBuilder.AppendFormat(" The package doesnt have a content folder matching the current project's target framework : {0}", dteHelper.GetProjectFramework());
                return(null);
            }

            //exclude the .transform files as they are treated separeately.
            List <IPackageFile> contentFiles = new List <IPackageFile>();

            foreach (IPackageFile file in compatibleItems)
            {
                if (!file.Path.EndsWith(".transform"))
                {
                    contentFiles.Add(file);
                }
            }

            if (contentFiles == null || contentFiles.Count == 0)
            {
                outputBuilder.AppendFormat(" No content files are present in the nupkg file.Skipping content validation");
                return(null);
            }

            foreach (IPackageFile file in contentFiles)
            {
                string filePath = file.Path.Remove(0, @"Content\".Length);
                if (file.Path.EndsWith(".pp"))
                {
                    filePath = filePath.Remove(filePath.Length - 3, 3);
                }
                filePath = Path.Combine(solutionPath, filePath);
                if (File.Exists(filePath))
                {
                    outputBuilder.AppendFormat("Content file : {0} added properly !!", file.Path);
                    outputBuilder.AppendLine();
                }
                else
                {
                    HasSuceeded = false;
                    errorBuilder.AppendFormat("Content file : {0} not added properly. Check the solution @ {1} for more details", file.Path, solutionPath);
                    errorBuilder.AppendLine();
                }
            }
            return(HasSuceeded);
        }
        public bool?Validate(string packageFullPath, VsProjectManager dteHelper)
        {
            string solutionPath = dteHelper.SolutionPath;

            HasSuceeded = true;

            Dictionary <string, string> referencesInProject = dteHelper.GetReferences();
            ZipPackage zipPackage = new ZipPackage(packageFullPath);
            List <FrameworkAssemblyReference> frameworkAssemblies = zipPackage.FrameworkAssemblies.ToList();

            if (frameworkAssemblies == null || frameworkAssemblies.Count == 0)
            {
                outputBuilder.Append("No Framework assemblies present in the package. Skipping the verification.");
                return(null);
            }

            //Get only thr framework assemblies which applies to the current project.
            frameworkAssemblies = frameworkAssemblies.Where(item => item.SupportedFrameworks.Contains(new FrameworkName(dteHelper.GetProjectFramework()))).ToList();

            foreach (FrameworkAssemblyReference frameworkassembly in frameworkAssemblies)
            {
                if (!referencesInProject.Keys.Contains(frameworkassembly.AssemblyName))
                {
                    HasSuceeded = false;
                    errorBuilder.AppendFormat(" Reference to the Framework Assembly {0} not added to the project. Check the solution @ {1} for more details.", frameworkassembly.AssemblyName, solutionPath);
                    errorBuilder.AppendLine();
                }
                else
                {
                    outputBuilder.AppendFormat(" Reference to the Framework Assembly {0} added properly.", frameworkassembly.AssemblyName);
                    outputBuilder.AppendLine();
                }
            }
            return(HasSuceeded);
        }