3F / MvsSln

🧩 Customizable VisualStudio .sln parser with project support (.vcxproj, .csproj., …). Pluggable lightweight r/w handlers at runtime, and more …
MIT License
140 stars 27 forks source link

Open an existing project --- Without a Solution... #37

Closed DynConcepts closed 3 years ago

DynConcepts commented 3 years ago

(Happy Holidays).... I would have thought this easy, but hours in, and no success...

3F commented 3 years ago

Thank you, and happy holidays to you too!

I would have thought this easy,

I think that's the way it is ~

var xp = new XProject("project file");

// ... do something
xp.GetProjectReferences().Count();

But for another powerful loading/managing take a look at IEnvironment -> IXProjectEnv; Here's old note

DynConcepts commented 3 years ago

Thanks... When i was "doing the crazy" of finding a solution that contained the project, then opening the solution, then selecting the project.... I was able to load a specific configuration... I do not see how to do that for a direct XPRoject constructor call...

OLD Code (for laughing)

                   List<net.r_eg.MvsSln.Core.ProjectItemCfg> proj = data.ProjectItemsConfigs.Where(p =>
                    (p.project.fullPath.ToLower() == projInfo.FullPath.ToLower()) &&
                    (p.projectConfig.Configuration.ToLower() == desiredConfiguration.ToLower()) && (p.projectConfig.Platform == desiredPlatform)
                    ).ToList();
                    if (proj.Count == 0)
                    {
                        SimpleLogger.WriteLine("Project Load Failure for Configuration");
                        return null;
                    }
                    if (proj.Count > 1)
                    {
                        SimpleLogger.WriteLine("Project Load Ambigious for Configuration");
                        return null;
                    }
                    data.Env.LoadProjects(new[] { proj[0] });
                    net.r_eg.MvsSln.Core.IXProject targetProject = data.Env.Projects.First();
3F commented 3 years ago

Not even sure what are you trying here :)

Environment implementations contains various loaders of the each project instances. This is manger where you can simply manage project collections through its single entity (the default implementations are IsolatedEnv/XProjectEnv).

For other cases you can use XProject or direct implementations (msbuild or future IeXod)