Beispiel #1
0
        public static string[] GetFileNames([NotNull] this EnvDTE.OutputGroup outputGroup)
        {
            Contract.Requires(outputGroup != null);
            Contract.Ensures(Contract.Result <string[]>() != null);

            return(InternalGetFileNames(outputGroup) ?? new string[0]);
        }
Beispiel #2
0
 private static IReadOnlyCollection <string>?InternalGetFileNames(this EnvDTE.OutputGroup outputGroup)
 {
     try
     {
         return(((Array)outputGroup.FileNames)?.OfType <string>().ToList().AsReadOnly());
     }
     catch
     {
         return(null);
     }
 }
Beispiel #3
0
 private static string[] InternalGetFileNames([NotNull] this EnvDTE.OutputGroup outputGroup)
 {
     try
     {
         return(((Array)outputGroup.FileNames)?.OfType <string>().ToArray());
     }
     catch
     {
         return(null);
     }
 }
        public static IEnumerable <string> GetFileNames([CanBeNull] this EnvDTE.OutputGroup outputGroup)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            try
            {
                return(((Array)outputGroup?.FileNames)?.OfType <string>());
            }
            catch
            {
                return(null);
            }
        }
Beispiel #5
0
 public static IEnumerable <string> GetFileNames(this EnvDTE.OutputGroup outputGroup)
 {
     return(InternalGetFileNames(outputGroup) ?? Array.Empty <string>());
 }
Beispiel #6
0
        private static IReadOnlyCollection <ProjectOutput> GetProjectOutputForGroup(Project project, EnvDTE.OutputGroup outputGroup, string binaryTargetDirectory)
        {
            var canonicalName = outputGroup.CanonicalName;

            if (!Enum.TryParse(canonicalName, out BuildFileGroups buildFileGroup))
            {
                throw new InvalidOperationException("Unknown output group: " + canonicalName);
            }

            var fileNames = outputGroup.GetFileNames();

            var projectOutputForGroup = fileNames.Select(fileName => new ProjectOutput(project, fileName, buildFileGroup, binaryTargetDirectory));

            return(projectOutputForGroup.ToList().AsReadOnly());
        }
        internal void getProjectFileInfo(string fileName, out string name, out string outputFile, out string configurationName, out string buildPath)
        {
            EnvDTE._DTE          dte = null;
            EnvDTE.Configuration config = null;
            string Name, OutputFile, ConfigurationName, BuildPath;

            buildPath         = String.Empty;
            configurationName = String.Empty;
            outputFile        = String.Empty;
            name = String.Empty;

            try
            {
                EnvDTE.Project     proj = null;
                EnvDTE.OutputGroup group = null;
                string             outputURLDir, projectFileDir;
                Object[]           OutputFiles = null;
                Object[]           OutputURLs  = null;
                int nIndex;

                dte = (EnvDTE._DTE) new VisualStudio_DTE_7_1();

                dte.Solution.AddFromFile(fileName, false);
                proj              = dte.Solution.Projects.Item(1);
                Name              = proj.Name;
                config            = proj.ConfigurationManager.ActiveConfiguration;
                ConfigurationName = config.ConfigurationName;

                // Loop through the possibly-many set of output groups, looking for the
                // one that has the build output. If we don't can't locate it, we will
                // attempt to use the first one in the list.
                nIndex = config.OutputGroups.Count;
                do
                {
                    group = config.OutputGroups.Item(nIndex);
                    nIndex--;
                } while ((nIndex > 0) && (group.CanonicalName != "Built"));

                OutputFiles = (Object[])group.FileNames;
                OutputFile  = (string)OutputFiles[0];

                OutputURLs   = (Object[])group.FileURLs;
                outputURLDir = (string)OutputURLs[0];

                // Given a full URL to the file path (file://c:\....) and the base path
                // to the project file (c:\...), determine the set of additional directories
                // into which the build is being performed.
                projectFileDir = getPath(fileName);
                projectFileDir = projectFileDir.ToUpper();
                outputURLDir   = outputURLDir.ToUpper();
                nIndex         = outputURLDir.LastIndexOf(projectFileDir);
                BuildPath      = outputURLDir.Substring(nIndex + projectFileDir.Length);
                BuildPath      = getPath(BuildPath);

                name              = Name;
                outputFile        = OutputFile;
                configurationName = ConfigurationName;
                buildPath         = BuildPath;
            }
            catch (System.Exception)
            {
                throw new System.Exception(SharedSupport.GetLocalizedString("ProjectInfo_ProjFileInvalid"));
            }
            finally
            {
                if (dte != null)
                {
                    try
                    {
                        dte.Solution.Close(false);
                        dte.Quit();
                    }
                    catch (System.Exception)
                    {
                        // Ignore errors when shutting down out-of-process IDE.
                    }
                }
            }
        }
Beispiel #8
0
        private static IReadOnlyCollection <ProjectOutput> GetProjectOutputForGroup([NotNull] Project project, [NotNull] EnvDTE.OutputGroup outputGroup, [NotNull] string binaryTargetDirectory)
        {
            Contract.Requires(project != null);
            Contract.Requires(outputGroup != null);
            Contract.Requires(binaryTargetDirectory != null);
            Contract.Ensures(Contract.Result <IEnumerable <ProjectOutput> >() != null);

            BuildFileGroups buildFileGroup;
            var             canonicalName = outputGroup.CanonicalName;

            if (!Enum.TryParse(canonicalName, out buildFileGroup))
            {
                throw new InvalidOperationException("Unknown output group: " + canonicalName);
            }

            var fileNames = outputGroup.GetFileNames();

            var projectOutputForGroup = fileNames.Select(fileName => new ProjectOutput(project, fileName, buildFileGroup, binaryTargetDirectory));

            return(projectOutputForGroup.ToArray());
        }
Beispiel #9
0
 public static string[] GetFileNames([NotNull] this EnvDTE.OutputGroup outputGroup)
 {
     return(InternalGetFileNames(outputGroup) ?? new string[0]);
 }