/// <summary> /// Sets up a 'project reference' to the project passed in. /// (See heading comment notes, and comments in setupReferences() above.) /// </summary> private void setupProjectReference(ReferenceInfo referenceInfo, ProjectInfo_CSharp referencedProject) { // For each configuration in this project, we find the equivalent // configuration in the referenced-project, and set up references // to its output folder... foreach (ProjectConfigurationInfo_CSharp configurationInfo in m_configurationInfos) { // We find the equivalent configuration from the referenced project... ProjectConfigurationInfo_CSharp referencedConfiguration = findEquivalentConfiguration(configurationInfo.Name, referencedProject); if (referencedConfiguration == null) { // The project has no equivalent configuration. (It probably // doesn't have any configurations at all.) continue; } // We find the absolute and relative path to the output of this // configuration... string absolutePath = referencedProject.RootFolderAbsolute + "/" + referencedConfiguration.OutputFolder + "/" + referencedProject.OutputFileName; absolutePath = Path.GetFullPath(absolutePath); string relativePath = Utils.makeRelativePath(m_rootFolderAbsolute, absolutePath); // We store the reference-info for each configuration... ReferenceInfo info = new ReferenceInfo(); info.CopyLocal = referenceInfo.CopyLocal; info.AbsolutePath = absolutePath; info.RelativePath = relativePath; info.ReferenceType = ReferenceInfo.ReferenceTypeEnum.PROJECT_REFERENCE; info.ConfigurationInfo = referencedConfiguration; configurationInfo.addReference(info); } }
/// <summary> /// Creates a copy of the data. /// </summary> public ReferenceInfo clone() { ReferenceInfo result = new ReferenceInfo(); result.AbsolutePath = AbsolutePath; result.ConfigurationInfo = ConfigurationInfo; result.CopyLocal = CopyLocal; result.ReferenceType = ReferenceType; result.RelativePath = RelativePath; return result; }
/// <summary> /// Creates a copy of the data. /// </summary> public ReferenceInfo clone() { ReferenceInfo result = new ReferenceInfo(); result.AbsolutePath = AbsolutePath; result.ConfigurationInfo = ConfigurationInfo; result.CopyLocal = CopyLocal; result.ReferenceType = ReferenceType; result.RelativePath = RelativePath; return(result); }
/// <summary> /// Adds a reference to this configuration. /// </summary> public void addReference(ReferenceInfo referenceInfo) { m_referenceInfos.Add(referenceInfo); if (referenceInfo.CopyLocal == true) { FileInfo fileInfo = new FileInfo(); fileInfo.AbsolutePath = referenceInfo.AbsolutePath; fileInfo.RelativePath = referenceInfo.RelativePath; fileInfo.CopyToOutputFolder = referenceInfo.CopyLocal; if (referenceInfo.ReferenceType == ReferenceInfo.ReferenceTypeEnum.PROJECT_REFERENCE) { fileInfo.IsFromAProjectOutputFolder = true; } m_filesToCopyToOutputFolder.Add(fileInfo); } }
/// <summary> /// Sets up 'external references' to the reference passed in. /// </summary> private void setupExternalReference(ReferenceInfo referenceInfo) { // We find the relative path to the reference from the project folder... string relativePath = Utils.makeRelativePath(m_rootFolderAbsolute, referenceInfo.AbsolutePath); // We set up the reference for each configuration in this project... foreach (ProjectConfigurationInfo_CSharp configurationInfo in m_configurationInfos) { // We store the reference-info for each configuration... ReferenceInfo info = new ReferenceInfo(); info.AbsolutePath = referenceInfo.AbsolutePath; info.RelativePath = relativePath; info.CopyLocal = referenceInfo.CopyLocal; info.ReferenceType = ReferenceInfo.ReferenceTypeEnum.EXTERNAL_REFERENCE; info.ConfigurationInfo = null; configurationInfo.addReference(info); } }
/// <summary> /// We set up the reference in all configurations of this project. /// (See notes in setupReferences above.) /// </summary> private void setupReference(ReferenceInfo referenceInfo) { // We check if the reference is pointing to another project in // the solution... ProjectInfo_CSharp referencedProject = findProjectReference(referenceInfo); if (referencedProject != null) { // The reference is to another project in the solution... setupProjectReference(referenceInfo, referencedProject); } else { // The reference is not to a project is the solution, // ie it is an 'external reference'... setupExternalReference(referenceInfo); } }
/// <summary> /// Adds a reference to the project. /// </summary> public void addReference(string fullPath, bool copyLocal) { // We do not add references to the core .NET assmeblies, // as they will be added to our mono projects with the // -pkg:dotnet option. string filename = Path.GetFileName(fullPath); if (filename.StartsWith("System.") == true || filename == "mscorlib.dll" || filename == "Microsoft.CSharp.dll") { return; } // We add the reference to the project. (But see the // heading-comment notes)... ReferenceInfo referenceInfo = new ReferenceInfo(); referenceInfo.AbsolutePath = fullPath; referenceInfo.CopyLocal = copyLocal; m_referenceInfos.Add(referenceInfo); }
/// <summary> /// Checks if the reference-info passed in comes from another project /// in the solution. /// Returns the referenced project if there is one, or null if the /// reference is not to another project in the solution. /// </summary> private ProjectInfo_CSharp findProjectReference(ReferenceInfo referenceInfo) { ProjectInfo_CSharp result = null; // We look through each project... foreach (ProjectInfo projectInfo in ParentSolution.getProjectInfos()) { // We are only interested in C# projects... ProjectInfo_CSharp csProjectInfo = projectInfo as ProjectInfo_CSharp; if (csProjectInfo == null) { continue; } // We check each configuration for the project... foreach (ProjectConfigurationInfo_CSharp configurationInfo in csProjectInfo.getConfigurationInfos()) { // We find the absolute path to the output for this configuration... string fullOutputPath = csProjectInfo.RootFolderAbsolute + "/" + configurationInfo.OutputFolder + "/" + csProjectInfo.OutputFileName; string fullIntermediatePath = csProjectInfo.RootFolderAbsolute + "/" + configurationInfo.IntermediateFolder + "/" + csProjectInfo.OutputFileName; // And we check if the reference passed points to the same assembly... if (Utils.isSamePath(fullOutputPath, referenceInfo.AbsolutePath) == true || Utils.isSamePath(fullIntermediatePath, referenceInfo.AbsolutePath) == true) { // We've found a match, so we return the project that this // configuration is a part of, as the reference appears to // be a 'project reference' to this project... return(csProjectInfo); } } } return(result); }
/// <summary> /// Checks if the reference-info passed in comes from another project /// in the solution. /// Returns the referenced project if there is one, or null if the /// reference is not to another project in the solution. /// </summary> private ProjectInfo_CSharp findProjectReference(ReferenceInfo referenceInfo) { ProjectInfo_CSharp result = null; // We look through each project... foreach (ProjectInfo projectInfo in ParentSolution.getProjectInfos()) { // We are only interested in C# projects... ProjectInfo_CSharp csProjectInfo = projectInfo as ProjectInfo_CSharp; if (csProjectInfo == null) { continue; } // We check each configuration for the project... foreach (ProjectConfigurationInfo_CSharp configurationInfo in csProjectInfo.getConfigurationInfos()) { // We find the absolute path to the output for this configuration... string fullOutputPath = csProjectInfo.RootFolderAbsolute + "/" + configurationInfo.OutputFolder + "/" + csProjectInfo.OutputFileName; string fullIntermediatePath = csProjectInfo.RootFolderAbsolute + "/" + configurationInfo.IntermediateFolder + "/" + csProjectInfo.OutputFileName; // And we check if the reference passed points to the same assembly... if (Utils.isSamePath(fullOutputPath, referenceInfo.AbsolutePath) == true || Utils.isSamePath(fullIntermediatePath, referenceInfo.AbsolutePath) == true) { // We've found a match, so we return the project that this // configuration is a part of, as the reference appears to // be a 'project reference' to this project... return csProjectInfo; } } } return result; }
/// <summary> /// Gets the relative path to the reference. Converts the output folder to our /// folder-style if it is a reference to another project in the solution. /// </summary> private string getReferenceRelativePath(ReferenceInfo referenceInfo) { switch(referenceInfo.ReferenceType) { case ReferenceInfo.ReferenceTypeEnum.EXTERNAL_REFERENCE: return referenceInfo.RelativePath; case ReferenceInfo.ReferenceTypeEnum.PROJECT_REFERENCE: { string prefix = MakeItSoConfig.Instance.getProjectConfig(m_projectInfo.Name).CSharpFolderPrefix; return Utils.addPrefixToFilePath(referenceInfo.RelativePath, prefix); } } return "(reference-path-not-found)"; }