[Rider] Editing .csproj from plugin

Answered

Hi,

i need to add ItemGroup to .csproj file or add child elements to existing one, like

I have access to JetBrains.ProjectModel.IProject from backend C# code and to com.intellij.openapi.project.Project from frontend Kotlin code

What's the correct way to do this excluding manual writing text to file by stream etc.?

0
2 comments

The easiest way to do it - implement the code like the next one in the backend:

var solution = project.GetSolution();
var solutionHost = solution.ProjectsHostContainer().GetComponent<ProjectsHost.SolutionHost.Impl.SolutionHost>();
var projectHost = solutionHost.GetProjectHost(projectMark) as MsBuildProjectHost;

if (projectHost  == null ) return;

projectHost.EditProject(ProjectMark, session =>
{
  session.AddItem(ProjectMark, itemType, include);
});
0

Evgeniy Stepanov That's what I need. Thanks!

0

Please sign in to leave a comment.