Exemple #1
0
        private void OnProjectOpened(IVsHierarchy vsHierarchy)
        {
            // Register pipe url so that MSBuild can transfer it
            var vsProject = vsHierarchy as IVsProject;

            if (vsProject != null)
            {
                var dteProject = VsHelper.ToDteProject(vsProject);

                // We will only deal with .csproj files for now
                // Should we support C++/CLI .vcxproj as well?
                if (!dteProject.FileName.EndsWith(".csproj"))
                {
                    return;
                }

                // Find current project active configuration
                var configManager = dteProject.ConfigurationManager;
                if (configManager == null)
                {
                    return;
                }

                EnvDTE.Configuration activeConfig;
                try
                {
                    activeConfig = configManager.ActiveConfiguration;
                }
                catch (Exception)
                {
                    if (configManager.Count == 0)
                    {
                        return;
                    }

                    activeConfig = configManager.Item(1);
                }

                // Get global parameters for Configuration and Platform
                var globalProperties = new Dictionary <string, string>();
                globalProperties["Configuration"] = activeConfig.ConfigurationName;
                globalProperties["Platform"]      = activeConfig.PlatformName == "Any CPU" ? "AnyCPU" : activeConfig.PlatformName;

                // Check if project matches: Condition="'$(XenkoCurrentPackagePath)' != '' and '$(XenkoIsExecutable)' == 'true'"
                var projectInstance      = new ProjectInstance(dteProject.FileName, globalProperties, null);
                var packagePathProperty  = projectInstance.Properties.FirstOrDefault(x => x.Name == "XenkoCurrentPackagePath");
                var isExecutableProperty = projectInstance.Properties.FirstOrDefault(x => x.Name == "XenkoIsExecutable");
                if (packagePathProperty == null || isExecutableProperty == null || isExecutableProperty.EvaluatedValue.ToLowerInvariant() != "true")
                {
                    return;
                }

                var buildProjects = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(dteProject.FileName);
                foreach (var buildProject in buildProjects)
                {
                    buildProject.SetGlobalProperty("XenkoBuildEngineLogPipeUrl", logPipeUrl);
                }
            }
        }
Exemple #2
0
        private void SolutionEventsListener_OnStartupProjectChanged(IVsHierarchy hierarchy)
        {
            if (configurationLock || hierarchy == null)
                return;

            currentStartupProject = VsHelper.ToDteProject(hierarchy);

            UpdateConfigurationFromStartupProject();
        }