Example #1
0
        /// <summary>
        /// Returns the full path of the assembly a project builds.
        /// </summary>
        /// <returns>The full path of the assembly this project builds.</returns>
        internal static string GetOutputPath(EnvDTE.Project automationProjectObject)
        {
            // Get the configuration manager from the project.
            EnvDTE.ConfigurationManager confManager = automationProjectObject.ConfigurationManager;
            if (null == confManager)
            {
                return(null);
            }

            // Get the active configuration.
            EnvDTE.Configuration config = confManager.ActiveConfiguration;
            if (null == config)
            {
                return(null);
            }

            // Get the output path for the current configuration.
            EnvDTE.Property outputPathProperty = config.Properties.Item("OutputPath");
            if (null == outputPathProperty)
            {
                return(null);
            }

            string outputPath = outputPathProperty.Value.ToString();

            // Ususally the output path is relative to the project path, but it is possible
            // to set it as an absolute path. If it is not absolute, then evaluate its value
            // based on the project directory.
            if (!System.IO.Path.IsPathRooted(outputPath))
            {
                string projectDir = System.IO.Path.GetDirectoryName(automationProjectObject.FullName);
                outputPath = System.IO.Path.Combine(projectDir, outputPath);
            }

            // Now get the name of the assembly from the project.
            // Some project system throw if the property does not exist. We expect an ArgumentException.
            EnvDTE.Property assemblyNameProperty = null;
            try
            {
                assemblyNameProperty = automationProjectObject.Properties.Item("OutputFileName");
            }
            catch (ArgumentException)
            {
            }

            if (null == assemblyNameProperty)
            {
                return(null);
            }
            else
            {
                outputPath = System.IO.Path.Combine(outputPath, assemblyNameProperty.Value.ToString());
            }

            // build the full path adding the name of the assembly to the output path.

            return(outputPath);
        }
 public VisualStudioConfiguration(SolutionContext solutionContext,
                                  EnvDTE.ConfigurationManager nativeConfigurationManager, string solutionConfiguration,
                                  string solutionPlatform)
 {
     this.solutionContext            = solutionContext;
     this.nativeConfigurationManager = nativeConfigurationManager;
     SolutionConfiguration           = solutionConfiguration;
     SolutionPlatform = solutionPlatform;
     SetAvailableConfigurationsAndPlatforms();
     SetIsBuildableAndIsDeployable();
 }
Example #3
0
        public static EnvDTE.Properties GetDtePropertiesFromHierarchy(IVsHierarchy hierarchy = null)
        {
            EnvDTE.Project project = GetDTEProjectFromHierarchy(hierarchy);
            if (project == null)
            {
                return(null);
            }

            EnvDTE.ConfigurationManager configManager = project.ConfigurationManager;
            if (configManager == null)
            {
                return(null);
            }

            EnvDTE.Configuration activeConfig = configManager.ActiveConfiguration;
            if (activeConfig == null)
            {
                return(null);
            }

            return(activeConfig.Properties);
        }
Example #4
0
 public void Dispose()
 {
     configurationManager = null;
 }
 public void Dispose() {
     configurationManager = null;
 }
Example #6
0
        public static string GetProjectOutputBuildFolder(EnvDTE.Project proj)
        {
            string absoluteOutputPath = null;
            string projectFolder      = Path.GetDirectoryName(proj.FullName);

            try
            {
                //Get the configuration manager of the project
                EnvDTE.ConfigurationManager configManager = proj.ConfigurationManager;

                if (configManager == null)
                {
                    QCPluginUtilities.OutputCommandString("The project " + proj.Name + " doesn't have a configuration manager", QCPluginUtilities.Severity.Error);
                }
                else
                {
                    //Get the active project configuration
                    EnvDTE.Configuration activeConfiguration = configManager.ActiveConfiguration;

                    //Get the output folder
                    string outputPath = activeConfiguration.Properties.Item("OutputPath").Value.ToString();

                    //The output folder can have these patterns:
                    //1) "\\server\folder"
                    //2) "drive:\folder"
                    //3) "..\..\folder"
                    //4) "folder"
                    if (outputPath.StartsWith(Path.DirectorySeparatorChar.ToString() + Path.DirectorySeparatorChar.ToString()))
                    {
                        //This is the case 1: "\\server\folder"
                        absoluteOutputPath = outputPath;
                    }
                    else if (outputPath.Length >= 2 && outputPath[1] == Path.VolumeSeparatorChar)
                    {
                        //This is the case 2: "drive:\folder"
                        absoluteOutputPath = outputPath;
                    }
                    else if (outputPath.IndexOf("..\\") > -1)
                    {
                        //This is the case 3: "..\..\folder"
                        while (outputPath.StartsWith("..\\"))
                        {
                            outputPath    = outputPath.Substring(3);
                            projectFolder = Path.GetDirectoryName(projectFolder);
                        }

                        absoluteOutputPath = Path.Combine(projectFolder, outputPath);
                    }
                    else
                    {
                        //This is the case 4: "folder"
                        projectFolder      = Path.GetDirectoryName(proj.FullName);
                        absoluteOutputPath = Path.Combine(projectFolder, outputPath);
                    }
                }
            }
            catch (Exception ex)
            {
                QCPluginUtilities.OutputCommandString("Get project output build folder error: " + ex.ToString(), QCPluginUtilities.Severity.Error);
            }

            return(absoluteOutputPath);
        }
Example #7
0
        public void BuildReferences()
        {
            if (this.references != null)
            {
                return;
            }

            this.references = new Dictionary <string, NDOReference>();
            var allProjects = new Dictionary <string, string>();
            var solution    = ApplicationObject.VisualStudioApplication.Solution;

            foreach (var p in new ProjectIterator(solution).Projects)
            {
                if (p.Name == project.Name)
                {
                    continue;
                }
                EnvDTE.ConfigurationManager cman = p.ConfigurationManager;
                if (cman == null)
                {
                    continue;
                }
                var conf = cman.ActiveConfiguration;
                if (conf.Properties == null)
                {
                    continue;
                }
                try // Skip the project, if a property is not present
                {
                    string outputPath     = (string)conf.Properties.Item("OutputPath").Value;
                    string fullPath       = (string)p.Properties.Item("FullPath").Value;
                    string outputFileName = GetBuildProperty(GetPropertyStorage(p), "TargetFileName");
                    //messages.Output(fullPath + outputPath + outputFileName);
                    if (!allProjects.ContainsKey(p.Name))
                    {
                        allProjects.Add(p.Name, fullPath + outputPath + outputFileName);
                    }
                }
                catch { }
            }


            foreach (var r in this.project.References)
            {
                string rname = "";
                //if (r.SourceProject != null)
                //    rname = r.SourceProject.Name;
                //else
                rname = r.Name;
                if (rname == project.Name)
                {
                    continue;
                }

                if (allProjects.ContainsKey(rname))
                {
                    AddReference(r.Name, (string)allProjects[rname], false);
                }
                else
                {
                    var vsRef = r.VsReference;
                    var path  = vsRef.FullPath;
                    // Referenzen, die auf keine gültige DLL verweisen...
                    if (!String.IsNullOrEmpty(path) && NDOAssemblyChecker.IsEnhanced(path))
                    {
                        AddReference(rname, path, false);
                    }
                }
            }
//			AddReference(project.Name, this.binFile);
        }