private IEnumerable <string> MigrateXProjProjectDependencies(MigrationRuleInputs migrationRuleInputs) { var csprojReferenceItems = _projectDependencyFinder.ResolveXProjProjectDependencies(migrationRuleInputs.ProjectXproj); if (!csprojReferenceItems.Any()) { return(Enumerable.Empty <string>()); } var csprojTransformedReferences = new List <ProjectItemElement>(); foreach (var csprojReferenceItem in csprojReferenceItems) { var conditionChain = csprojReferenceItem.ConditionChain(); var condition = string.Join(" and ", conditionChain); var referenceInclude = string.Join(";", csprojReferenceItem.Includes() .Where(include => string.Equals(Path.GetExtension(include), ".csproj", StringComparison.OrdinalIgnoreCase))); var transformItem = ProjectDependencyStringTransform.Transform(referenceInclude); transformItem.Condition = condition; csprojTransformedReferences.Add(transformItem); } MigrationTrace.Instance.WriteLine(String.Format(LocalizableStrings.MigratingCountXprojToCsprojReferences, nameof(MigrateProjectDependenciesRule), csprojTransformedReferences.Count())); foreach (var csprojTransformedReference in csprojTransformedReferences) { _transformApplicator.Execute(csprojTransformedReference, migrationRuleInputs.CommonItemGroup, true); } return(csprojTransformedReferences.SelectMany(r => r.Includes())); }
private IEnumerable <string> MigrateXProjProjectDependencies(MigrationSettings migrationSettings, MigrationRuleInputs migrationRuleInputs) { var xproj = migrationRuleInputs.ProjectXproj; if (xproj == null) { MigrationTrace.Instance.WriteLine($"{nameof(MigrateProjectDependenciesRule)}: No xproj file given."); return(Enumerable.Empty <string>()); } var csprojTransformedReferences = new List <ProjectItemElement>(); var csprojReferenceItems = xproj.Items .Where(i => i.ItemType == "ProjectReference") .Where(p => p.Includes().Any( include => string.Equals(Path.GetExtension(include), ".csproj", StringComparison.OrdinalIgnoreCase))); foreach (var csprojReferenceItem in csprojReferenceItems) { var conditionChain = csprojReferenceItem.ConditionChain(); var condition = string.Join(" and ", conditionChain); var referenceInclude = string.Join(";", csprojReferenceItem.Includes() .Where(include => string.Equals(Path.GetExtension(include), ".csproj", StringComparison.OrdinalIgnoreCase))); var transformItem = ProjectDependencyStringTransform.Transform(referenceInclude); transformItem.Condition = condition; csprojTransformedReferences.Add(transformItem); } MigrationTrace.Instance.WriteLine($"{nameof(MigrateProjectDependenciesRule)}: Migrating {csprojTransformedReferences.Count()} xproj to csproj references"); foreach (var csprojTransformedReference in csprojTransformedReferences) { _transformApplicator.Execute(csprojTransformedReference, migrationRuleInputs.CommonItemGroup); } return(csprojTransformedReferences.SelectMany(r => r.Includes())); }