private static List <KeyValuePair <IvyModule, string> > GetIvyModules(Project project) { var ivyModules = new List <KeyValuePair <IvyModule, string> >(); var projectDirectory = new DirectoryInfo(Path.GetDirectoryName(project.FullName)); var workspaceDirectory = new DirectoryInfo( (!string.IsNullOrEmpty(Options.Instance.WorkspacePath) ? Options.Instance.WorkspacePath : projectDirectory.Parent.FullName)); if (!workspaceDirectory.Exists) { Output.Instance.WriteLine("The specified workspace directory doesn't exist, can't continue looking for ivy.xml files"); return(ivyModules); } FileInfo[] ivyFiles = workspaceDirectory.GetFiles("ivy.xml", SearchOption.AllDirectories); foreach (FileInfo ivyFile in ivyFiles) { IvyModule ivyModule = XmlFileSerializer <IvyModule> .Deserialize(ivyFile.FullName); ivyModules.Add(new KeyValuePair <IvyModule, string>(ivyModule, ivyFile.FullName)); } return(ivyModules); }
public Installer(IvyModule package) { this.package = package; base.Name = "Installer Task"; string path = Path.Combine(Settings.installLocation, "task-installer-" + base.JobId); if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, package.ToString()); }
public static Installer FromExisting(string path) { IvyModule package = IvyParser.ParseFile <IvyModule>(path); if (package == null) { return(null); } string g = Path.GetFileName(path).Substring("task-installer-".Length); return(new Installer(package, new Guid(g))); }
private static InternalPackageInfo Parse(string moduleFile) { if (moduleFile == null) { return(null); } IvyModule ivyModule = IvyParser.ParseFile <IvyModule>(moduleFile); if (IvyParser.HasErrors) { Console.WriteLine("Error parsing module description from {0}. {1}", moduleFile, IvyParser.ErrorMessage); return(null); } return(new InternalPackageInfo { module = ivyModule, package = ivyModule.ToPackageInfo() }); }
private void HandleOnUpdate(IvyModule[] modules) { this.m_RequestRepaint = true; }
public Installer(IvyModule package, Guid id) : base(id) { this.package = package; base.Name = "Installer Task"; base.Restarted = true; }
private static string GetCalculatedReferencePath(string projectDirectoryPath, IvyModule ivyModule, Artifact artifact, string referenceFileName) { string dependenciesRetrievePattern = @"Dependencies\[organisation]\[module]\[artifact].[type]"; if (string.IsNullOrEmpty(Options.Instance.DependenciesPattern)) { Output.Instance.WriteLine(@"There is no dependencies retrieve pattern set, will default to Dependencies\[organisation]\[module]\[artifact].[type]"); } else { dependenciesRetrievePattern = Options.Instance.DependenciesPattern; } return(projectDirectoryPath + Path.DirectorySeparatorChar + dependenciesRetrievePattern .Replace("[organisation]", ivyModule.Info.Organisation) .Replace("[module]", ivyModule.Info.Module) .Replace("[branch]", ivyModule.Info.Branch) .Replace("[revision]", ivyModule.Info.Revision) .Replace("[artifact]", artifact.Name) .Replace("[type]", artifact.Type) .Replace("[ext]", artifact.Extension) .Replace("[conf]", artifact.Configuration) .Replace("[originalname]", artifact.Filename)); }
public static void UnresolveProject(Solution4 solution, Projects projects, Project project) { var solutionDirectoryPath = Path.GetDirectoryName(solution.FullName); // can be moved out side this method var projectDirectoryPath = Path.GetDirectoryName(project.FullName); VSProject2 vsProject = project.Object as VSProject2; // load ivymodules List <KeyValuePair <IvyModule, string> > ivyModules = GetIvyModules(project); References references = vsProject.References; // http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/03d9d23f-e633-4a27-9b77-9029735cfa8d/ string fullPath = project.Properties.Item("FullPath").Value.ToString(); string outputPath = project.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString(); string outputDir = Path.Combine(fullPath, outputPath); // very important! we need to delete the output dir since it won't otherwise add references with and hintpath, instead it references the binary to their bin\Debug directory, took forever to understand! Directory.Delete(outputDir, true); foreach (Reference3 reference in references) { // do only check for assemlby references which has is a project reference and it its directory should not be a part of the solution. since we don't want to resolve our main project if (reference.Type == prjReferenceType.prjReferenceTypeAssembly && reference.SourceProject != null && !reference.SourceProject.FullName.Contains(solutionDirectoryPath)) { var referenceFileName = Path.GetFileName(reference.Path); IvyModule foundIvyModule = null; string foundIvyModulePath = null; Artifact foundIvyModuleArtifact = null; foreach (KeyValuePair <IvyModule, string> kvp in ivyModules) { IvyModule ivyModule = kvp.Key; string ivyModulePath = kvp.Value; foreach (Artifact artifact in ivyModule.Publications.ArtifactList) { if (artifact.Filename == referenceFileName) { foundIvyModule = ivyModule; foundIvyModulePath = ivyModulePath; foundIvyModuleArtifact = artifact; break; } } if (foundIvyModule != null) { break; } } if (foundIvyModule == null) { Output.Instance.WriteLine("Could not find a matching ivy module for reference '" + reference.Name + "'"); continue; } // the calulated path to the binary reference var referenceFile = new FileInfo(GetCalculatedReferencePath(projectDirectoryPath, foundIvyModule, foundIvyModuleArtifact, referenceFileName)); Output.Instance.WriteLine("Found a matching ivy module for reference '" + reference.Name + "', assumed path to the binary file is '" + referenceFile.FullName + "'"); if (!referenceFile.Exists) { Output.Instance.WriteLine("The reference file does not exist, assure that you'r following the patterns for dependencies."); continue; } reference.Remove(); vsProject.References.Add(referenceFile.FullName); } } project.Save(project.FullName); if (!projectDirectoryPath.Contains(solutionDirectoryPath)) { solution.Remove(project); } }