Exemplo n.º 1
0
        /// <summary>
        /// Adds refresh files to the specified project for all assemblies references belonging to the packages specified by packageNames.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="packagesFileSystem">The file system pointing to 'packages' folder under the solution.</param>
        /// <param name="packageNames">The package names.</param>
        private void AddRefreshFilesForReferences(Project project, string repositoryPath, IEnumerable <PackageIdentity> packageNames)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (repositoryPath == null)
            {
                throw new ArgumentNullException("repositoryPath");
            }

            if (!packageNames.Any())
            {
                return;
            }

            VSAPIProjectContext  context       = new VSAPIProjectContext();
            WebSiteProjectSystem projectSystem = new WebSiteProjectSystem(project, context);

            var root = EnvDTEProjectUtility.GetFullPath(project);

            foreach (var packageName in packageNames)
            {
                string packagePath = String.Format(CultureInfo.InvariantCulture, "{0}.{1}", packageName.Id, packageName.Version);

                DirectoryInfo packageFolder = new DirectoryInfo(Path.Combine(repositoryPath, packagePath));

                PackageFolderReader reader = new PackageFolderReader(packageFolder);

                var frameworkGroups = reader.GetReferenceItems();

                var groups = reader.GetReferenceItems();

                var fwComparer           = new NuGetFrameworkFullComparer();
                FrameworkReducer reducer = new FrameworkReducer();
                NuGetFramework   targetGroupFramework = reducer.GetNearest(projectSystem.TargetFramework, groups.Select(e => e.TargetFramework));

                if (targetGroupFramework != null)
                {
                    var refGroup = groups.Where(e => fwComparer.Equals(targetGroupFramework, e.TargetFramework)).FirstOrDefault();

                    foreach (string refItem in refGroup.Items)
                    {
                        string sourcePath = Path.Combine(packageFolder.FullName, refItem.Replace('/', Path.DirectorySeparatorChar));

                        // create one refresh file for each assembly reference, as per required by Website projects
                        // projectSystem.CreateRefreshFile(assemblyPath);
                        RefreshFileUtility.CreateRefreshFile(projectSystem, sourcePath, context);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private IEnumerable <ProjectInfo> GetProjectFolderPath()
        {
            var projects = _dte.Solution.Projects;

            foreach (var item in projects)
            {
                var project = item as Project;

                if (project != null)
                {
                    yield return(new ProjectInfo(EnvDTEProjectUtility.GetFullPath(project), project.Name));
                }
            }
        }
Exemplo n.º 3
0
        private async Task <bool> CheckPackagesConfigAsync()
        {
            return(await NuGetUIThreadHelper.JoinableTaskFactory.RunAsync(async() =>
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                var dte = _serviceProvider.GetDTE();
                var projects = dte.Solution.Projects;
                return projects
                .OfType <EnvDTE.Project>()
                .Select(p => new ProjectInfo(EnvDTEProjectUtility.GetFullPath(p), p.Name))
                .Any(p => p.CheckPackagesConfig());
            }));
        }