4 using System.Collections.Generic;
6 using Microsoft.Build.Evaluation;
7 using Microsoft.Build.Execution;
8 using Microsoft.VisualStudio;
9 using Microsoft.VisualStudio.Shell.Interop;
11 namespace SiliconStudio.
Paradox.VisualStudio
15 private string logPipeUrl =
"net.pipe://localhost/Paradox.BuildEngine.Monitor." + Guid.NewGuid();
18 public string LogPipeUrl
20 get {
return logPipeUrl; }
27 solutionEventsListener.AfterProjectOpened += OnProjectOpened;
30 var solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
33 IEnumHierarchies enumerator;
34 var guid = Guid.Empty;
35 var hierarchy =
new IVsHierarchy[1] { null };
38 solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref guid, out enumerator);
39 for (enumerator.Reset(); enumerator.Next(1, hierarchy, out fetched) == VSConstants.S_OK && fetched == 1; )
41 OnProjectOpened(hierarchy[0]);
46 private void OnProjectOpened(IVsHierarchy vsHierarchy)
49 var vsProject = vsHierarchy as IVsProject;
50 if (vsProject != null)
52 var dteProject = VsHelper.ToDteProject(vsProject);
56 if (!dteProject.FileName.EndsWith(
".csproj"))
60 var configManager = dteProject.ConfigurationManager;
61 if (configManager == null)
64 EnvDTE.Configuration activeConfig;
67 activeConfig = configManager.ActiveConfiguration;
71 if (configManager.Count == 0)
74 activeConfig = configManager.Item(1);
78 var globalProperties =
new Dictionary<string, string>();
79 globalProperties[
"Configuration"] = activeConfig.ConfigurationName;
80 globalProperties[
"Platform"] = activeConfig.PlatformName ==
"Any CPU" ?
"AnyCPU" : activeConfig.PlatformName;
83 var projectInstance =
new ProjectInstance(dteProject.FileName, globalProperties, null);
84 var packagePathProperty = projectInstance.Properties.FirstOrDefault(x => x.Name ==
"SiliconStudioCurrentPackagePath");
85 var isExecutableProperty = projectInstance.Properties.FirstOrDefault(x => x.Name ==
"SiliconStudioIsExecutable");
86 if (packagePathProperty == null || isExecutableProperty == null || isExecutableProperty.EvaluatedValue.ToLowerInvariant() !=
"true")
89 var buildProjects = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(dteProject.FileName);
90 foreach (var buildProject
in buildProjects)
92 buildProject.SetGlobalProperty(
"SiliconStudioBuildEngineLogPipeUrl", logPipeUrl);
BuildLogPipeGenerator(IServiceProvider serviceProvider)