コード例 #1
0
        private bool Init(string runsourceProject, VSProjectUpdateOptions options)
        {
            CompilerProjectReader runsourceProjectReader = CompilerProjectReader.Create(new XmlConfig(runsourceProject).GetConfigElement("/AssemblyProject"));
            string vsProject = runsourceProjectReader.GetVSProject();

            if (vsProject == null)
            {
                Trace.WriteLine($"visual studio project is not defined");
                return(false);
            }
            if (!zFile.Exists(vsProject))
            {
                Trace.WriteLine($"visual studio project not found \"{vsProject}\"");
                return(false);
            }
            _vsProjectManager = new VSProjectManager(vsProject);

            _runsourceProjectsReaders = new List <CompilerProjectReader>();
            _runsourceProjectsReaders.Add(runsourceProjectReader);
            foreach (string complementaryProject in runsourceProjectReader.GetComplementaryProjects())
            {
                _runsourceProjectsReaders.Add(CompilerProjectReader.Create(new XmlConfig(complementaryProject).GetConfigElement("/AssemblyProject")));
            }
            _options = options;
            return(true);
        }
コード例 #2
0
        public static void TraceVSProject(string vsProject = null)
        {
            if (vsProject != null)
            {
                vsProject = RunSourceCommand.GetFilePath(RunSourceCommand.GetProjectVariableValue(vsProject));
            }
            else
            {
                vsProject = GetVSProject(RunSourceCommand.GetCurrentProject());
            }

            if (!zFile.Exists(vsProject))
            {
                Trace.WriteLine($"visual studio project not found \"{vsProject}\"");
                return;
            }

            try
            {
                //RunSourceCommand.TraceDisableViewer();
                ////RunSourceCommand.TraceSetWriter(WriteToFile.Create(zPath.Combine(zPath.GetDirectoryName(vsProject), zPath.GetFileName(vsProject) + ".trace.txt"), FileOption.RazFile), "trace");
                //RunSourceCommand.TraceSetWriter(WriteToFile.Create(vsProject + ".trace.txt", FileOption.RazFile), "trace");
                RunSourceCommand.TraceManager.DisableViewer();
                RunSourceCommand.TraceManager.SetWriter(WriteToFile.Create(vsProject + ".trace.txt", FileOption.RazFile), "trace");

                Trace.WriteLine($"visual studio project \"{vsProject}\"");
                VSProjectManager vsProjectManager = new VSProjectManager(vsProject);
                Trace.WriteLine("  sources");
                foreach (VSSource source in vsProjectManager.GetSources().Where(source => source.Link == null).OrderBy(source => source.File))
                {
                    //Trace.WriteLine($"    file \"{sourceLink.File}\" link \"{sourceLink.Link}\"");
                    //if (source.Link == null)
                    Trace.WriteLine($"    \"{source.File}\"");
                }
                Trace.WriteLine("  sources links");
                foreach (VSSource source in vsProjectManager.GetSources().Where(source => source.Link != null).OrderBy(source => source.File))
                {
                    //Trace.WriteLine($"    file \"{sourceLink.File}\" link \"{sourceLink.Link}\"");
                    //if (source.Link != null)
                    Trace.WriteLine($"    \"{source.File}\"");
                }
                Trace.WriteLine("  framework references");
                foreach (VSReference reference in vsProjectManager.GetReferences().Where(reference => reference.File == null).OrderBy(reference => reference.Name))
                {
                    Trace.WriteLine($"    \"{reference.Name}\"");
                }
                Trace.WriteLine("  dll references");
                foreach (VSReference reference in vsProjectManager.GetReferences().Where(reference => reference.File != null && !reference.ProjectReference).OrderBy(reference => reference.Name))
                {
                    Trace.WriteLine($"    {("\"" + reference.Name + "\""),-70} \"{reference.File}\"");
                    //if (reference.File == null)
                    //    Trace.WriteLine($"    \"{reference.Name}\"");
                    //else if (reference.ProjectReference)
                    //    //Trace.WriteLine($"    \"{reference.Name}\" \"{reference.File}\" project \"{reference.ProjectReference}\"");
                    //    Trace.WriteLine($"    \"{reference.Name,-70}\" \"{reference.File}\"");
                    //else
                    //    Trace.WriteLine($"    \"{reference.Name,-70}\" \"{reference.File}\"");
                }
                Trace.WriteLine("  project references");
                foreach (VSReference reference in vsProjectManager.GetReferences().Where(reference => reference.ProjectReference).OrderBy(reference => reference.Name))
                {
                    Trace.WriteLine($"    {("\"" + reference.Name + "\""),-70} \"{reference.File}\"");
                }
            }
            finally
            {
                //RunSourceCommand.TraceRemoveWriter("trace");
                //RunSourceCommand.TraceEnableViewer();
                RunSourceCommand.TraceManager.RemoveWriter("trace");
                RunSourceCommand.TraceManager.EnableViewer();
            }
        }