Configurations and Projects/Colutions Oh My... #42
Replies: 2 comments 6 replies
-
|
Additional info... This would also need to remove any other elements that were specific to the removed configuration/platform. At this point pretty sure that the package does not support this as a single call (but still hopeful), but perhaps someone has previously developed a snipped and can share. NOTE: The Project Configuration/Platform most likely does NOT exist in the Solution!!!!!! |
Beta Was this translation helpful? Give feedback.
-
|
How about using var sln = new Sln(@"D:\prg\issues\MvsSln\issue40\TestStruct\TestStruct.sln", SlnItems.Env);
sln.Result.Env
.LoadProjects(sln.Result.ProjectItemsConfigs.Where(p => p.solutionConfig.Platform == "x64"))
.ForEach(xp => // TODO: more like we need add this as part of MvsSln, https://github.com/3F/DllExport/blob/c1cc52fa13f563f97a2b4fe08bfb541c69195866/Wizard/Extensions/XProjectExtension.cs#L121
xp.Project.Xml.PropertyGroups.Where(p =>
// NOTE: projectConfig should contain default IRuleOfConfig impl to avoid misunderstanding between "Any CPU" and "AnyCPU", or like;
// MS "Any CPU" bug was described here: https://github.com/3F/vsSolutionBuildEvent/issues/14#issuecomment-246419276
p.Condition.Contains($"'{xp.ProjectItem.projectConfig.ConfigurationByRule}|{xp.ProjectItem.projectConfig.PlatformByRule}'")
)
.ForEach(p => p.Parent?.RemoveChild(p))
.E(_ => xp.Save())
);
Make sure about the "Any CPU" / "AnyCPU". You can simply use the default rules or implement something for the mentioned IRuleOfConfig
Just add something else together with PropertyGroups logic above |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The VS GUI allows you do delete a Solution config, but that does not iterate through projects. I want to delete "ALL" project configurations and platforms except for a specific one...
I can iterate through them and identify them, but can not find the object to call a "remove like" method on...
var allprojectConfigs = data.ProjectItemsConfigs.ToList(); List<ProjectItemCfg> toRemove = new List<ProjectItemCfg>(); foreach (ProjectItemCfg projectConfig in allprojectConfigs) { if (projectConfig.projectConfig.Platform == "x64") { Microsoft.Build.Evaluation.Project loadedProject = sln.Result.Env.GetOrLoadProject(projectConfig.project); toRemove.Add(projectConfig); } } // OK, now kill everything in the "toRemove" list"Beta Was this translation helpful? Give feedback.
All reactions