-1

I have got a VS solution, which looks like this:

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demonstation", "Demonstation\Demonstation.csproj", "{8ABE7A72-527A-4E18-8442-9632F1AA83D5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Folder 1", "Folder 1", "{416E314D-54A7-4A98-955D-86513A1EDBBF}"
    ProjectSection(SolutionItems) = preProject
        XMLFile1.xml = XMLFile1.xml
    EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Folder 2", "Folder 2", "{B955928E-FADA-413D-839B-3A2D72A63A06}"
    ProjectSection(SolutionItems) = preProject
        TextFile1.txt = TextFile1.txt
    EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Folder 3", "Folder 3", "{AA6C508F-817F-42F8-A3F8-2450BCC03FC5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Important", "Important\Important.csproj", "{F7A45E90-5F30-4F5E-9EFA-F44AB260A731}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "even_more_important", "even_more_important\even_more_important.csproj", "{23C38EED-2893-406D-8184-7004C2F2D57F}"
EndProject
Global
    GlobalSection(SolutionConfigurationPlatforms) = preSolution
        Debug|Any CPU = Debug|Any CPU
        Release|Any CPU = Release|Any CPU
    EndGlobalSection
    GlobalSection(ProjectConfigurationPlatforms) = postSolution
        {8ABE7A72-527A-4E18-8442-9632F1AA83D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {8ABE7A72-527A-4E18-8442-9632F1AA83D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {8ABE7A72-527A-4E18-8442-9632F1AA83D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {8ABE7A72-527A-4E18-8442-9632F1AA83D5}.Release|Any CPU.Build.0 = Release|Any CPU
        {F7A45E90-5F30-4F5E-9EFA-F44AB260A731}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {F7A45E90-5F30-4F5E-9EFA-F44AB260A731}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {F7A45E90-5F30-4F5E-9EFA-F44AB260A731}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {F7A45E90-5F30-4F5E-9EFA-F44AB260A731}.Release|Any CPU.Build.0 = Release|Any CPU
        {23C38EED-2893-406D-8184-7004C2F2D57F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
        {23C38EED-2893-406D-8184-7004C2F2D57F}.Debug|Any CPU.Build.0 = Debug|Any CPU
        {23C38EED-2893-406D-8184-7004C2F2D57F}.Release|Any CPU.ActiveCfg = Release|Any CPU
        {23C38EED-2893-406D-8184-7004C2F2D57F}.Release|Any CPU.Build.0 = Release|Any CPU
    EndGlobalSection
    GlobalSection(SolutionProperties) = preSolution
        HideSolutionNode = FALSE
    EndGlobalSection
    GlobalSection(NestedProjects) = preSolution
        {8ABE7A72-527A-4E18-8442-9632F1AA83D5} = {416E314D-54A7-4A98-955D-86513A1EDBBF}
        {F7A45E90-5F30-4F5E-9EFA-F44AB260A731} = {B955928E-FADA-413D-839B-3A2D72A63A06}
        {23C38EED-2893-406D-8184-7004C2F2D57F} = {AA6C508F-817F-42F8-A3F8-2450BCC03FC5}
    EndGlobalSection
EndGlobal

As you can see, there are 3 folders.

My task is to delete folder 1 with everything inside (files+subdir) from the solution with c#, visual studio and msbuild. I have already searched through the internet for finding a similar problem. Unfortunately, I haven't found any posts, which could help me with my specific problem except these two:

How do i build a solution programmatically in C#?

api to check for project variables and reference paths in a project file

What I need are some coding examples for getting acquainted with msbuild and helpful hints how to solve this task.

Thanks in advance for your answers!

With best regards New Ubuntu User

Community
  • 1
  • 1
Coding4Fun
  • 81
  • 1
  • 9
  • Possible duplicate of [Best practices for editing sln, proj, suo files?](http://stackoverflow.com/questions/3877290/best-practices-for-editing-sln-proj-suo-files) – stijn Apr 20 '16 at 08:10

1 Answers1

0

There is no documented API for dealing with solution files (which are not msbuild files btw, so you have been looking in the wrong place)...

Unless you have to do this for tens of files, it'll be way faster to just open the solution in the IDE and delete everything from there. Alternative solutions:

  • open the file in a text editor and delete some lines
  • figure out which assemblies are used by VS to read/write solution files and use them for your needs
  • write your own text-based parser (in C# or whatever language suits you best) for solution files
stijn
  • 34,664
  • 13
  • 111
  • 163
  • Hi stijn , thank you for your response. Actually, I need to deal with two solution files and my supervisors would like that I code something in C#. – Coding4Fun Apr 20 '16 at 08:29
  • Well, that doesn't change my answer in anyway. So unless this is some kind of programming exercise to figure out if you're capable, I'd tell the supervisor there are probably better things to spend time on. – stijn Apr 20 '16 at 08:36