Esempio n. 1
0
        protected TProp propertiesByDefault(TProp properties)
        {
            if (!properties.ContainsKey("Configuration"))
            {
                // ~
                if (_sln.configs.Count > 0)
                {
                    properties["Configuration"] = _sln.configs[0].configuration;
                }
                else
                {
                    properties["Configuration"] = "Release";
                }
            }

            if (!properties.ContainsKey("Platform"))
            {
                // ~
                if (_sln.configs.Count > 0)
                {
                    properties["Platform"] = _sln.configs[0].platform;
                }
                else
                {
                    properties["Platform"] = "x86";
                }
            }
            else
            {
                properties["Platform"] = platformName(properties["Platform"]);
            }

            return(properties);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets instance of the Build.Evaluation.Project for accessing to properties etc.
        /// </summary>
        /// <param name="name">Specified project name. null value for project by default (~startup-project etc.)</param>
        /// <returns>Microsoft.Build.Evaluation.Project</returns>
        public virtual Project getProject(string name = null)
        {
            Log.Trace("getProject: started with '{0}'", name);

            if (String.IsNullOrEmpty(name))
            {
                name = StartupProjectString;
                Log.Trace("getProject: use the StartupProject '{0}'", name);
            }
            Sln.Project project;

            foreach (Project eProject in ProjectCollection.GlobalProjectCollection.LoadedProjects)
            {
                string eConfiguration = eProject.GetPropertyValue("Configuration");
                string ePlatform      = eProject.GetPropertyValue("Platform");
                string eCfg           = formatCfg(eConfiguration, ePlatform);

                Log.Trace($"find in projects collection: `{eProject.FullPath}`");
                project = _sln.projects.Find(p => p.fullPath == eProject.FullPath);

                if (project.pGuid == null || project.fullPath == null)
                {
                    continue;
                }

                TProp prop = projectProperties(project, slnProperties);
                Log.Trace($" ? {prop["Configuration"]}|{prop["Platform"]} == {eCfg}");

                if (eCfg == formatCfg(prop["Configuration"], prop["Platform"]))
                {
                    return(eProject);
                }
            }

            project = _sln.projects.Find(p => p.name == name);

            Log.Trace("trying to load project :: '{0}' ('{1}')", project.name, project.fullPath);
            if (String.IsNullOrEmpty(project.fullPath))
            {
                throw new NotFoundException("Missed path to project '{0}' ['{1}', '{2}']", name, project.name, project.pGuid);
            }

            return(new Project(
                       project.fullPath,
                       projectProperties(project, slnProperties),
                       null,
                       ProjectCollection.GlobalProjectCollection
                       ));
        }
Esempio n. 3
0
        /// <param name="solutionFile">Full path to solution file (.sln)</param>
        /// <param name="properties">Solution properties / global properties for all project collection</param>
        public IsolatedEnv(string solutionFile, TProp properties)
        {
            SolutionFile     = solutionFile;
            SolutionPath     = Path.GetDirectoryName(SolutionFile);
            SolutionFileName = Path.GetFileNameWithoutExtension(SolutionFile);

            _sln = (new Sln.Parser()).parse(SolutionFile);

            if (String.IsNullOrEmpty(StartupProjectString))
            {
                updateStartupProject(null);
            }
            IsOpenedSolution = true;

            slnProperties = propertiesByDefault(properties);
            foreach (KeyValuePair <string, string> property in properties)
            {
                ProjectCollection.GlobalProjectCollection.SetGlobalProperty(property.Key, property.Value);
            }
        }
Esempio n. 4
0
        protected TProp projectProperties(Sln.Project project, TProp properties)
        {
            Log.Debug($"-> sln['{properties["Configuration"]}'; '{properties["Platform"]}']");

            if (!properties.ContainsKey("Configuration") || !properties.ContainsKey("Platform"))
            {
                Log.Warn("Solution Configuration & Platform are not defined.");
                return(properties);
            }
            TProp ret = new TProp(properties);

            var cfg = _sln
                      .projectConfigs
                      .Where(c =>
                             c.pGuid == project.pGuid &&
                             c.sln.configuration == properties["Configuration"] &&
                             platformName(c.sln.platform) == platformName(properties["Platform"])
                             )
                      .FirstOrDefault();

            if (cfg.configuration == null || cfg.platform == null)
            {
                Log.Warn($"Something went wrong with project configuration. `{cfg.configuration}|{cfg.platform}`");
                Log.Warn($"Are you sure that it's correct for your sln: `{properties["Configuration"]}|{properties["Platform"]}`");
                return(properties);
                //throw new MismatchException();
            }

            string platform = platformName(cfg.platform);

            Log.Debug($"-> prj['{cfg.configuration}'; '{platform}']");

            ret["Configuration"] = cfg.configuration;
            ret["Platform"]      = platform;

            return(ret);
        }
Esempio n. 5
0
 /// <summary>
 /// Blank instance.
 /// </summary>
 /// <param name="properties">Solution properties.</param>
 public IsolatedEnv(TProp properties)
 {
     slnProperties = properties;
 }
 /// <summary>
 /// Blank instance.
 /// </summary>
 /// <param name="properties">Solution properties.</param>
 public IsolatedEnv(TProp properties)
 {
 }