Exemple #1
0
 public ExternalModule(IProjectReference reference, string path)
 {
     ArtifactId = reference.ArtifactId;
     GroupId    = reference.GroupId;
     Version    = reference.Version;
     FullPath   = path;
 }
Exemple #2
0
        // REVIEW: need review. switch to notify changed schema
        public void PropagateVersionToUsages(IProjectReference projectReference)
        {
            bool usageUpdated = false;

            if (HasProjectAsParent(projectReference, false))
            {
                if (_project.Parent.Version != projectReference.Version)
                {
                    _project.Parent.Version = projectReference.Version;
                    usageUpdated            = true;
                }
            }

            foreach (var dependency in AllDependencies.Where(d => d.ReferenceOperations().ReferenceEqualTo(projectReference, false)))
            {
                if (dependency.Version.IsDefined && dependency.Version != projectReference.Version)
                {
                    dependency.Version = projectReference.Version;
                    usageUpdated       = true;
                }
            }

            foreach (var plugin in AllPlugins.Where(d => d.ReferenceOperations().ReferenceEqualTo(projectReference, false)))
            {
                if (plugin.Version.IsDefined && plugin.Version != projectReference.Version)
                {
                    plugin.Version = projectReference.Version;
                    usageUpdated   = true;
                }
            }

            // TODO: Changed = usageUpdated;
        }
Exemple #3
0
        /// <summary>
        /// Removes references that have
        /// the Temp attribute and which
        /// were added from the Dependencies
        /// and FrameworkAssemblies sections
        /// of the lock file.
        /// </summary>
        public virtual IEnumerable <string> SwitchDependency(IProjectReference reference, ReferenceType type)
        {
            HashSet <string> output = new
                                      HashSet <string>
                                          ();

            foreach (ProjectItem item in GetTempItem(reference, type))
            {
                if (type == ReferenceType.ProjectReference)
                {
                    output.Add(item.EvaluatedInclude);
                }

                // Implicit.
                if (!item.HasMetadata("Version"))
                {
                    reference.MsbProject.RemoveItem(item);
                }
                // Explicit.
                else
                {
                    item.UnevaluatedInclude = item.GetMetadataValue("Temp");

                    item.RemoveMetadata("Temp");
                    item.RemoveMetadata("Name");

                    item.ItemType = Type.ToString();
                }

                MessageProvider.AddMessage(reference.UniqueName, $"Dependency: { Path.GetFileNameWithoutExtension(item.EvaluatedInclude) } has been switched back. Type: { Type }", MessageCategory.ME);
            }

            return(output);
        }
Exemple #4
0
        // REVIEW: need review. switch to notify changed schema
        public void PropagateVersionToUsages(IProjectReference projectReference)
        {
            if (HasProjectAsParent(projectReference, false))
            {
                if (Project.Parent.Version != projectReference.Version)
                {
                    Project.Parent.Version = projectReference.Version;
                    Changed = true;
                }
            }

            foreach (var dependency in Project.AllDependencies.Where(d => d.ReferenceEqualTo(projectReference, false)))
            {
                if (dependency.Version != projectReference.Version)
                {
                    dependency.Version = projectReference.Version;
                    Changed            = true;
                }
            }

            foreach (var plugin in Project.AllPlugins.Where(d => d.ReferenceEqualTo(projectReference, false)))
            {
                if (plugin.HasSpecificVersion && plugin.Version != projectReference.Version)
                {
                    plugin.Version = projectReference.Version;
                    Changed        = true;
                }
            }
        }
        /// <summary>
        /// Adds reference to the project. It is assumed
        /// that the original reference has been removed
        /// earlier.
        /// </summary>
        ///
        /// <param name="unevaluatedInclude">
        /// Must contain the assembly
        /// name or the absolute path
        /// to the project or Package
        /// Id.
        /// </param>
        ///
        /// <exception cref="SwitcherException"/>
        ///
        /// <returns>
        /// Returns false for duplicate <paramref name="unevaluatedInclude"/> values.
        /// </returns>
        protected virtual bool AddReference(IProjectReference reference, ReferenceType type, string unevaluatedInclude, Dictionary <string, string> metadata)
        {
            bool output = true;

            switch (type)
            {
            case ReferenceType.ProjectReference:
            case ReferenceType.PackageReference:
            case ReferenceType.Reference:
                if (reference.MsbProject.GetItemsByEvaluatedInclude(unevaluatedInclude).Any())
                {
                    output = false;
                }
                else
                {
                    reference.MsbProject.AddItem(type.ToString(), unevaluatedInclude, AdaptMetadata(unevaluatedInclude, metadata));
                }
                break;

            default:
                throw new SwitcherException(reference.MsbProject, $"Reference type not supported: { type }");
            }

            if (output)
            {
                MessageProvider.AddMessage(reference.MsbProject.FullPath, $"Dependency: { Path.GetFileName(unevaluatedInclude) } has been added. Type: { type }", MessageCategory.ME);
            }

            return(output);
        }
Exemple #6
0
        public override void CreateChickenNugetProject(IProjectReference proj)
        {
            if (ReadChickenNugetProject(proj, false) != null)
            {
                throw new Exception("Already has file");
            }

            var packageConfigs = this.GetAllNugetPackagesConfig(proj, false);
            var nuspecs        = this.GetAllNugetSpecFiles(proj, false);

            if (packageConfigs.Length == 0 && nuspecs.Length == 0)
            {
                return;
            }

            var project = (ProjectReference)proj;
            var client  = CreateRestClient();
            var request = new RestRequest("/projects/{id}/repository/files/{file_path}", Method.POST, DataFormat.Json);

            request.Parameters.Add(new Parameter("id", project.Id, ParameterType.UrlSegment));
            request.Parameters.Add(new Parameter("file_path", ChkngtProjectFilePath, ParameterType.UrlSegment));

            request.Parameters.Add(new Parameter("branch", "master", ParameterType.GetOrPost));
            request.Parameters.Add(new Parameter("author_email", AuthorEmailAddress, ParameterType.GetOrPost));
            request.Parameters.Add(new Parameter("author_name", AuthorName, ParameterType.GetOrPost));
            request.Parameters.Add(new Parameter("content", AssembleChickenNugetProject(packageConfigs, nuspecs), ParameterType.GetOrPost));
            request.Parameters.Add(new Parameter("commit_message", "Create chicken nuget file.", ParameterType.GetOrPost));

            var response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.Created)
            {
                throw new Exception("Failed to create file");
            }
        }
Exemple #7
0
        public ApplyVersionFix(IProjectReference reference, ComponentVersion version)
        {
            _reference = reference;
            _version   = version;

            Title = $"version will be changed to {version}";
        }
Exemple #8
0
 public bool ReferenceEqualTo(IProjectReference another, bool strictVersion = true)
 {
     return
         (GroupIdEqual(_projectReference.GroupId, another.GroupId) &&
          _projectReference.ArtifactId.Equals(another.ArtifactId, StringComparison.Ordinal) &&
          ((strictVersion == false) || VersionEqual(_projectReference.Version, another.Version)));
 }
Exemple #9
0
        public VersionFix(Project project, IProjectReference reference, string version)
        {
            _project   = project;
            _reference = reference;
            _version   = version;

            Title = string.Format("version will be changed to {0}", version);
        }
Exemple #10
0
        // my parent reference is equal to project reference
        public bool HasProjectAsParent(IProjectReference projectReference, bool strictVersion)
        {
            var parentReference = _project.Parent;

            return
                (parentReference != null &&
                 parentReference.ReferenceOperations().ReferenceEqualTo(projectReference, strictVersion));
        }
Exemple #11
0
        internal AddToExternalFix(ExternalModulesRepository externalModules, IProjectReference externalReference)
        {
            _externalModules   = externalModules;
            _externalReference = externalReference;

            ShouldBeConfirmed = true;
            Title             = "Mark as external module";
        }
Exemple #12
0
        private bool HasProjectAsParent(IProjectReference projectReference, bool strictVersion)
        {
            var parentReference = Project.Parent;

            return
                (parentReference != null &&
                 parentReference.ReferenceEqualTo(projectReference, strictVersion));
        }
Exemple #13
0
        public bool HasProjectReference(string projectFilePath, out IProjectReference projectReference)
        {
            projectReference = this.ProjectReferences.Where(x => x.ProjectFilePath == projectFilePath).SingleOrDefault();

            var hasProjectReference = projectReference == default;

            return(hasProjectReference);
        }
Exemple #14
0
        public SpecFlowConfigurationHolder ReadConfiguration(IProjectReference projectReference)
        {
            var vsProjectReference = VsProjectReference.AssertVsProjectReference(projectReference);
            ProjectItem projectItem = VsxHelper.FindProjectItemByProjectRelativePath(vsProjectReference.Project, "app.config");
            if (projectItem == null)
                return new SpecFlowConfigurationHolder();

            string configFileContent = VsxHelper.GetFileContent(projectItem);
            return GetConfigurationHolderFromFileContent(configFileContent);
        }
        /// <summary>
        /// Includes references to the GAC assemblies
        /// listed in the FrameworkAssemblies section
        /// of the lock file.
        /// </summary>
        public virtual void SwitchSysDependency(IProjectReference reference, LockFileTargetLibrary library)
        {
            Dictionary <string, string> metadata = new
                                                   Dictionary <string, string>
                                                       (1);

            foreach (string assembly in library.FrameworkAssemblies)
            {
                base.AddReference(reference, ReferenceType.Reference, assembly, metadata);
            }
        }
        /// <summary>
        /// Returns the <see cref="LockFileTarget"/> section
        /// for a project TFM from the lock file provided by
        /// <see cref="LockFile"/>.
        /// </summary>
        ///
        /// <exception cref="SwitcherFileNotFoundException"/>
        protected virtual LockFileTarget GetProjectTarget(IProjectReference reference)
        {
            NuGetFramework nf = new
                                NuGetFramework(reference.TFI, new Version(reference.TFV));

            return(GetLockFile(reference).GetTarget(nf, string.Empty) ??

                   new LockFileTarget()
            {
                Libraries = new List <LockFileTargetLibrary>()
            });
        }
Exemple #17
0
        public bool TryGetProject(IProjectReference reference, out IProject project, bool strictVersion = true)
        {
            var operation = reference.ReferenceOperations();

            project = AllProjects.
                      SingleOrDefault(p =>
            {
                var r = _extractor.Extract(p);
                return(operation.ReferenceEqualTo(r, strictVersion));
            });
            return(project != null);
        }
Exemple #18
0
        public bool RemoveProjectReference(IProjectReference projectReference)
        {
            var hasAnyProjectReferences = this.ProjectXElement.HasProjectReferencesItemGroupElement(out var projectReferencesItemGroupXElement);

            if (!hasAnyProjectReferences)
            {
                return(false);
            }

            var success = projectReferencesItemGroupXElement.RemoveProjectReference(projectReference);

            return(success);
        }
Exemple #19
0
        public bool IsItUsed(IProjectReference projectReference)
        {
            var creteria = new SearchOptions
            {
                LookForParents   = true,
                LookForDependent = true,
                LookForPlugin    = true,
                OnlyDirectUsages = true,
                StrictVersion    = true
            };

            return(AllProjectNodes.Any(node => node.UsesProjectAs(projectReference, creteria)));
        }
Exemple #20
0
        public SpecFlowConfigurationHolder ReadConfiguration(IProjectReference projectReference)
        {
            var         vsProjectReference = VsProjectReference.AssertVsProjectReference(projectReference);
            ProjectItem projectItem        = VsxHelper.FindProjectItemByProjectRelativePath(vsProjectReference.Project, "app.config");

            if (projectItem == null)
            {
                return(new SpecFlowConfigurationHolder());
            }

            string configFileContent = VsxHelper.GetFileContent(projectItem);

            return(GetConfigurationHolderFromFileContent(configFileContent));
        }
Exemple #21
0
        public override IChickenNugetProject ReadChickenNugetProject(IProjectReference reference, bool clearCache)
        {
            var cache = SimpleCache <Tuple <int, string>, IChickenNugetProject> .CreateCache("Source-Project-ChickenNugetProject");

            if (!clearCache)
            {
                var cacheObj = cache.Get(new Tuple <int, string>(this.Config.Id, reference.GetIdentifier()));
                if (cacheObj != null)
                {
                    return(cacheObj);
                }
            }

            var project = (ProjectReference)reference;

            if (project.ChickenNugetProject != null)
            {
                return(project.ChickenNugetProject);
            }

            var client   = CreateRestClient();
            var request  = CreateFileReadRequest(project, ChkngtProjectFilePath, "master");
            var response = client.Execute(request);

            if (response.StatusCode == HttpStatusCode.NotFound)
            {
                return(null);
            }
            if (response.ErrorException != null)
            {
                throw new Exception("Failed to read ChickenNuget file", response.ErrorException);
            }

            var json = response.ToJsonObject();

            var configsJson = (JArray)json["files"]["packages-config"];
            var nuspecsJson = (JArray)json["files"]["package-nuspec"];

            var configs = configsJson?.Select(x => (IProjectFile)CreateProjectFileFromPath(reference, x.Value <string>())).ToArray();
            var nuspecs = nuspecsJson?.Select(x => (IProjectFile)CreateProjectFileFromPath(reference, x.Value <string>())).ToArray();

            var chickenNugetProject = new ChickenNugetProject(configs ?? new IProjectFile[0], nuspecs ?? new IProjectFile[0]);

            project.ChickenNugetProject = chickenNugetProject;

            cache.Insert(new Tuple <int, string>(this.Config.Id, reference.GetIdentifier()), chickenNugetProject);

            return(chickenNugetProject);
        }
        public SpecFlowProject ReadSpecFlowProject(IProjectReference projectReference)
        {
            var projectFilePath = FileProjectReference.AssertFileProjectReference(projectReference).ProjectFilePath;

            var project = Engine.GlobalEngine.GetLoadedProject(projectFilePath);

            if (project == null)
            {
                project = new Microsoft.Build.BuildEngine.Project();
                project.Load(projectFilePath, ProjectLoadSettings.IgnoreMissingImports);
            }

            string projectFolder = Path.GetDirectoryName(projectFilePath);

            SpecFlowProject specFlowProject = new SpecFlowProject();

            specFlowProject.ProjectSettings.ProjectFolder    = projectFolder;
            specFlowProject.ProjectSettings.ProjectName      = Path.GetFileNameWithoutExtension(projectFilePath);
            specFlowProject.ProjectSettings.AssemblyName     = project.GetEvaluatedProperty("AssemblyName");
            specFlowProject.ProjectSettings.DefaultNamespace = project.GetEvaluatedProperty("RootNamespace");

            var items = project.GetEvaluatedItemsByName("None").Cast <BuildItem>()
                        .Concat(project.GetEvaluatedItemsByName("Content").Cast <BuildItem>());

            foreach (BuildItem item in items)
            {
                var extension = Path.GetExtension(item.FinalItemSpec);
                if (extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase))
                {
                    var featureFile = new FeatureFileInput(item.FinalItemSpec);
                    var ns          = item.GetEvaluatedMetadata("CustomToolNamespace");
                    if (!String.IsNullOrEmpty(ns))
                    {
                        featureFile.CustomNamespace = ns;
                    }
                    specFlowProject.FeatureFiles.Add(featureFile);
                }

                if (Path.GetFileName(item.FinalItemSpec).Equals("app.config", StringComparison.InvariantCultureIgnoreCase))
                {
                    var configFilePath      = Path.Combine(projectFolder, item.FinalItemSpec);
                    var configFileContent   = File.ReadAllText(configFilePath);
                    var configurationHolder = GetConfigurationHolderFromFileContent(configFileContent);
                    specFlowProject.ProjectSettings.ConfigurationHolder = configurationHolder;
                    specFlowProject.Configuration = configurationLoader.LoadConfiguration(configurationHolder, projectReference);
                }
            }
            return(specFlowProject);
        }
Exemple #23
0
        public bool HasProjectReference(string projectFilePath, out IProjectReference projectReference)
        {
            var hasAnyProjectReferences = this.ProjectXElement.HasProjectReferencesItemGroupElement(out var projectReferencesItemGroupXElement);

            if (!hasAnyProjectReferences)
            {
                projectReference = ProjectReferenceHelper.None;

                return(false);
            }

            var hasProjectReference = projectReferencesItemGroupXElement.HasProjectReference(projectFilePath, out projectReference);

            return(hasProjectReference);
        }
Exemple #24
0
        // TODO: TEST
        internal IProjectValidationProblem ValidateReference(IProject project, IProjectReference reference, string referenceTitle)
        {
            IProjectReferenceOperations operation = reference.ReferenceOperations();

            var potencial = _context.AllAvailableProjectReferences.
                            Where(p => operation.ReferenceEqualTo(p, false)).ToArray();

            if (potencial.Length == 0)
            {
                return(new ValidationProblem(referenceTitle + "missing")                 // TODO: fixable
                {
                    ProjectReference = project,
                    Severity = ProblemSeverity.ProjectWarning,
                    Description = string.Format("uses unknown {0} {1}", referenceTitle, reference)
                });
                //error.AddFix(new AddExternalModuleFix(_externalModules, dependency));
            }

            // REVIEW: First is enougth
            // REVIEW: many exact matches is not a problem of project reference, but need to be catched differently
            var exact = potencial.FirstOrDefault(p => reference.Version == p.Version);

            if (exact != null)
            {
                return(null);
            }

            if (potencial.Length == 1)
            {
                return(new ValidationProblem(referenceTitle + "versionmissmatch")                 // TODO: fixable
                {
                    ProjectReference = project,
                    Severity = ProblemSeverity.ProjectWarning,
                    Description = string.Format("version of {0} different from {1}", referenceTitle, reference)
                });
                //		error.AddFix(new ApplyVersionFix(_projectNode.Project, dependency, potencial.Single().Version));
            }
            return(new ValidationProblem(referenceTitle + "version")             // TODO: fixable
            {
                ProjectReference = project,
                Severity = ProblemSeverity.ProjectWarning,
                Description = string.Format("version of {0} different from {1}. Found multiple potencial candidates", referenceTitle, reference)
            });
            //		foreach (var candicate in potencial)
            //		{
            //			error.AddFix(new ApplyVersionFix(_projectNode.Project, dependency, candicate.Version));
            //		}
        }
        public virtual SpecFlowProjectConfiguration LoadConfiguration(SpecFlowConfigurationHolder configurationHolder, IProjectReference projectReference)
        {
            SpecFlowProjectConfiguration configuration = new SpecFlowProjectConfiguration();

            if (configurationHolder != null && configurationHolder.HasConfiguration)
            {
                ConfigurationSectionHandler specFlowConfigSection = ConfigurationSectionHandler.CreateFromXml(configurationHolder.XmlString);
                if (specFlowConfigSection != null)
                {
                    configuration.GeneratorConfiguration.UpdateFromConfigFile(specFlowConfigSection);
                    configuration.RuntimeConfiguration.UpdateFromConfigFile(specFlowConfigSection);
                }
            }
            configuration.GeneratorConfiguration.GeneratorVersion = GetGeneratorVersion(projectReference);
            return configuration;
        }
        public SpecFlowProject ReadSpecFlowProject(IProjectReference projectReference)
        {
            var projectFilePath = FileProjectReference.AssertFileProjectReference(projectReference).ProjectFilePath;

            var project = Engine.GlobalEngine.GetLoadedProject(projectFilePath);
            if (project == null)
            {
                project = new Microsoft.Build.BuildEngine.Project();
                project.Load(projectFilePath, ProjectLoadSettings.IgnoreMissingImports);
            }

            string projectFolder = Path.GetDirectoryName(projectFilePath);

            SpecFlowProject specFlowProject = new SpecFlowProject();
            specFlowProject.ProjectSettings.ProjectFolder = projectFolder;
            specFlowProject.ProjectSettings.ProjectName = Path.GetFileNameWithoutExtension(projectFilePath);
            specFlowProject.ProjectSettings.AssemblyName = project.GetEvaluatedProperty("AssemblyName");
            specFlowProject.ProjectSettings.DefaultNamespace = project.GetEvaluatedProperty("RootNamespace");

            var items = project.GetEvaluatedItemsByName("None").Cast<BuildItem>()
                .Concat(project.GetEvaluatedItemsByName("Content").Cast<BuildItem>());
            foreach (BuildItem item in items)
            {
                var extension = Path.GetExtension(item.FinalItemSpec);
                if (extension.Equals(".feature", StringComparison.InvariantCultureIgnoreCase))
                {
                    var featureFile = new FeatureFileInput(item.FinalItemSpec);
                    var ns = item.GetEvaluatedMetadata("CustomToolNamespace");
                    if (!String.IsNullOrEmpty(ns))
                        featureFile.CustomNamespace = ns;
                    specFlowProject.FeatureFiles.Add(featureFile);
                }

                if (Path.GetFileName(item.FinalItemSpec).Equals("app.config", StringComparison.InvariantCultureIgnoreCase))
                {
                    var configFilePath = Path.Combine(projectFolder, item.FinalItemSpec);
                    var configFileContent = File.ReadAllText(configFilePath);
                    var configurationHolder = GetConfigurationHolderFromFileContent(configFileContent);
                    specFlowProject.ProjectSettings.ConfigurationHolder = configurationHolder;
                    specFlowProject.Configuration = configurationLoader.LoadConfiguration(configurationHolder, projectReference);
                }
            }
            return specFlowProject;
        }
Exemple #27
0
        public void StoreCacheProjectFiles(string key, IProjectReference project, IProjectFile[] value)
        {
            using (var db = CreateStorage())
            {
                var caches     = GetProjectFileCache(db);
                var identifier = project.GetIdentifier();
                caches.Delete(c => c.ConfigurationId == _config.Id && c.Key == key && c.ProjectIdentifier == identifier);

                var cache = new ProjectFileListCache()
                {
                    Key               = key,
                    ConfigurationId   = _config.Id,
                    ProjectIdentifier = identifier,
                    Files             = value.Select(x => _source.PackProjectFile(x)).ToArray(),
                };

                caches.Upsert(cache);
            }
        }
Exemple #28
0
        public bool UsesProjectAs(IProjectReference projectReference, SearchOptions creteria)
        {
            if (creteria.LookForParents && HasProjectAsParent(projectReference, creteria.StrictVersion))
            {
                return(true);
            }

            if (creteria.LookForDependent && HasDependencyOn(projectReference, creteria.StrictVersion))
            {
                return(true);
            }

            if (creteria.LookForPlugin && UsesPlugin(projectReference, creteria.StrictVersion))
            {
                return(true);
            }

            return(false);
        }
Exemple #29
0
        private ProjectFile CreateProjectFileFromPath(IProjectReference reference, string path)
        {
            var project = (ProjectReference)reference;
            var client  = CreateRestClient();
            var request = new RestRequest("/projects/{id}/repository/files/{file_path}", Method.GET, DataFormat.Json);

            request.Parameters.Add(new Parameter("id", project.Id, ParameterType.UrlSegment));
            request.Parameters.Add(new Parameter("file_path", path, ParameterType.UrlSegment));
            request.Parameters.Add(new Parameter("ref", "master", ParameterType.QueryString));

            var json = client.Execute(request).ToJsonObject();

            var id          = json["blob_id"].Value <string>();
            var name        = json["file_name"].Value <string>();
            var type        = "blob";
            var fPath       = json["file_path"].Value <string>();
            var projectFile = new ProjectFile(id, name, type, fPath);

            return(projectFile);
        }
Exemple #30
0
        protected override Version GetGeneratorVersion(IProjectReference projectReference)
        {
            var vsProjectScopeReference = VsProjectScopeReference.AssertVsProjectScopeReference(projectReference);

            //HACK: temporary solution: we use the SpecFlow runtime version as generator version, to avoid unwanted popups reporting outdated tests
            try
            {
                VSProject vsProject = (VSProject) vsProjectScopeReference.Project.Object;
                var specFlowRef =
                    vsProject.References.Cast<Reference>().FirstOrDefault(r => r.Name == "TechTalk.SpecFlow");
                if (specFlowRef != null)
                    return new Version(specFlowRef.Version);
            }
            catch(Exception exception)
            {
                Debug.WriteLine(exception, "VsSpecFlowProjectConfigurationLoader.GetGeneratorVersion");
            }

            return vsProjectScopeReference.VsProjectScope.GeneratorServices.GetGeneratorVersion();
        }
Exemple #31
0
        public override IProjectFile[] GetAllNugetSpecFiles(IProjectReference reference, bool clearCache)
        {
            var config = ReadChickenNugetProject(reference, clearCache);

            if (config != null)
            {
                return(config.NuspecFiles);
            }
            var cacheControl = this.GetCacheControl();
            var nugetFiles   = cacheControl.GetCacheProjectFiles("nuspec", reference);

            if (nugetFiles != null)
            {
                return(nugetFiles);
            }
            var allProjectFiles = GetAllProjectFiles(reference, clearCache);

            nugetFiles = allProjectFiles.Where(x => ((ProjectFile)x).Name.EndsWith(".nuspec", StringComparison.OrdinalIgnoreCase)).ToArray();
            cacheControl.StoreCacheProjectFiles("nuspec", reference, nugetFiles);
            return(nugetFiles);
        }
Exemple #32
0
 private static Task FetchDependencyMapItems(IProjectSource source, IProjectReference project, List <Tuple <IProjectReference, Dictionary <Tuple <IProjectFile, IProjectInformation>, NugetDependency[]>, Dictionary <IProjectFile, NugetDefinition> > > model)
 {
     return(Task.Run(() =>
     {
         try
         {
             var nugetDep = source.GetAllNugetDependencies(project, false);
             var nugetDef = source.GetAllNugetDefinitions(project, false);
             // Dictionary<Tuple<IProjectFile, IProjectInformation>, NugetDependency[]>
             if (nugetDep.Count > 0 || nugetDep.Count > 0)
             {
                 model.Add(new Tuple <IProjectReference, Dictionary <Tuple <IProjectFile, IProjectInformation>, NugetDependency[]>, Dictionary <IProjectFile, NugetDefinition> >
                               (project, nugetDep, nugetDef));
             }
         }
         catch (Exception ex)
         {
             throw new Exception("Failed for project: " + project.GetName(), ex);
         }
     }));
 }
        /// <summary>
        /// Includes implicit, explicit project references
        /// listed in the Dependencies section of the lock
        /// file.
        /// </summary>
        ///
        /// <exception cref="SwitcherException"/>
        ///
        /// <remarks>
        /// Implicit dependencies mean transitive.
        /// </remarks>
        public virtual void SwitchPkgDependency(IProjectReference reference, LockFileTargetLibrary library, string absolutePath)
        {
            /*
             * References can be represented by several values in
             * an ItemGroup, for example, when included using the
             * Condition attribute.
             */

            ICollection <ProjectItem> items = reference.MsbProject.GetItemsByEvaluatedInclude(library.Name);

            // Implicit.
            if (!items.Any())
            {
                base.AddReference(reference, Type, absolutePath, new Dictionary <string, string>(2)
                {
                    { "Name", library.Name }
                });
            }
            // Explicit.
            else
            {
                /*
                 * Re-creating an item can lead to the loss
                 * of user metadata; in order to avoid this,
                 * the item is redefined.
                 */

                foreach (ProjectItem item in items)
                {
                    item.ItemType = Type.ToString();

                    item.SetMetadataValue("Temp", item.EvaluatedInclude);
                    item.SetMetadataValue("Name", item.EvaluatedInclude);

                    item.UnevaluatedInclude = absolutePath;
                }

                MessageProvider.AddMessage(reference.MsbProject.FullPath, $"Dependency: {library.Name } has been switched. Type: { Type }", MessageCategory.ME);
            }
        }
Exemple #34
0
        protected override Version GetGeneratorVersion(IProjectReference projectReference)
        {
            var vsProjectScopeReference = VsProjectScopeReference.AssertVsProjectScopeReference(projectReference);

            //HACK: temporary solution: we use the SpecFlow runtime version as generator version, to avoid unwanted popups reporting outdated tests
            try
            {
                VSProject vsProject   = (VSProject)vsProjectScopeReference.Project.Object;
                var       specFlowRef =
                    vsProject.References.Cast <Reference>().FirstOrDefault(r => r.Name == "TechTalk.SpecFlow");
                if (specFlowRef != null)
                {
                    return(new Version(specFlowRef.Version));
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception, "VsSpecFlowProjectConfigurationLoader.GetGeneratorVersion");
            }

            return(vsProjectScopeReference.VsProjectScope.GeneratorServices.GetGeneratorVersion());
        }
 protected override Version GetGeneratorVersion(IProjectReference projectReference)
 {
     return TestGeneratorFactory.GeneratorVersion;
 }
 static public AppDomainProjectReference AssertFileProjectReference(IProjectReference projectReference)
 {
     return (AppDomainProjectReference)projectReference; //TODO: better error handling
 }
 protected abstract Version GetGeneratorVersion(IProjectReference projectReference);
Exemple #38
0
 static public VsProjectScopeReference AssertVsProjectScopeReference(IProjectReference projectReference)
 {
     return (VsProjectScopeReference)projectReference; //TODO: better error handling
 }