Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Solution Folder #6

Closed
OneManMonkeySquad opened this issue Mar 1, 2019 · 7 comments
Closed

Create Solution Folder #6

OneManMonkeySquad opened this issue Mar 1, 2019 · 7 comments
Labels

Comments

@OneManMonkeySquad
Copy link

Hello,

as far as I can see, I can't create new project folders or assign projects to folder. Our build system generates a flat list of 400 C++ projects and I want to categorize them.

@3F
Copy link
Owner

3F commented Mar 1, 2019

Solution Folders(items) are possible through:

  • LProjectSolutionItems (reader handler)
  • WProjectSolutionItems (writer handler)
    IEnumerable<SolutionFolder> SolutionFolders

So you can try to create new folder and/or its items in the same manner like from my example here.

  • Just create/modify list of SolutionFolder instances. Then push vice versa through related writer.

Let me know if you can't something, I'll prepare some example later.

@3F 3F added the question label Mar 1, 2019
@OneManMonkeySquad
Copy link
Author

OneManMonkeySquad commented Mar 1, 2019

Any clue on how to get the NestedProjects section populated?

GlobalSection(NestedProjects) = preSolution
    {9E2D0B92-DA21-418C-9F9A-3C896110B992} = {2E05BAA3-EB03-46F9-8C52-232DB0D837EB}
EndGlobalSection

SolutionFolder takes a list of RawTexts for single files, but no projects? Quick hint please :D Also, seems I'm not properly writing the sln. The writer duplicates all project decls.

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "src\Core\Core.vcxproj", "{E075AD0E-2E65-3CFD-9E5E-C07B9CDDF9E3}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "src\Core\Core.vcxproj", "{E075AD0E-2E65-3CFD-9E5E-C07B9CDDF9E3}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "src\Core\Core.vcxproj", "{E075AD0E-2E65-3CFD-9E5E-C07B9CDDF9E3}"

@3F
Copy link
Owner

3F commented Mar 1, 2019

Today's way for creating solution folder looks like:

var folders = new List<SolutionFolder>(sln.Result.SolutionFolders)
{
    new SolutionFolder
    (
        new ProjectItem()
        {
            pType = Guids.SLN_FOLDER,
            name = "MyFolder1",
            path = "MyFolder1", // recommended to be same
            pGuid = Guid.NewGuid().ToString()
        },
        new List<RawText>()
        {
            ".gnt\\gnt.core",
            ".gnt\\packages.config",
            // ...
        }
    ),
    //...
};

handlers for this case as I said:

var whandlers = new Dictionary<Type, HandlerValue>() {
    [typeof(LProjectSolutionItems)] = new HandlerValue(new WProjectSolutionItems(folders)),
};

But seems we have no handlers for NestedProjects when solution folders, sorry for the inconvenience :(

I've plan to implement this, follow the news.

@3F
Copy link
Owner

3F commented Mar 1, 2019

Any clue on how to get the NestedProjects section

ah yes, forgot to say about map. I don't recommend this, but anyway, just for clarify before support.

In any case, you can easily get access to any lines of loaded .sln.

As it was illustrated:

The Map property from result contains all lines which are already processed with handlers and which are still not.

So we can get anything to manual processing. However, this is not recommended way.

Because I specially prepared flexible architecture to add any custom handlers (including user space) for any lines which are still not processed (or for multiple processing).

Thus, temporarily you can try to add your custom handler, then just register it in listeners for common use.

I think we need also add some documentation for this <_<

But of course, MvsSln should support this by default. Ticket above.

@OneManMonkeySquad
Copy link
Author

Thank you for your quick answer :)

I decided to implement this with a rather long python script. It's crude but it does the job. A list of things to consider when implementing this might help you:

  • folders inside folders
  • folders having the same name on different levels of the tree
  • moving projects into folders
  • getting or creating a folder with the same method (GetOrCreateFolder)

@3F
Copy link
Owner

3F commented Mar 6, 2019

It will be implemented later anyway. At least by me.

In fact, the main features was extracted from vsSolutionBuildEvent project. Mainly for DllExport, but I also had plans in past for just splitting something like this including its script engine etc.

That is, this feature was simply not required to someone(including me) for all that period :)

But MvsSln should really cover it. Basically, we just need to implement ISlnHandler and IObjHandler with related logic for new handlers. It shouldn't be hard.

I will look into later. More probably this March, well, as possible for my time. Also follow the new issue.

@3F
Copy link
Owner

3F commented Apr 1, 2019

You can test new features starting from CI-build-37 https://github.com/3F/MvsSln/releases

Planned for 2.2

new SolutionFolder("dir1", 
    new SolutionFolder("dir2", 
        new SolutionFolder("dir3", "hMSBuild.bat", "DllExport.bat")
    )
);
...
new ProjectItem("Project1", ProjectType.Cs, new SolutionFolder("dir1"));

#8 (comment)

@sirpolly

getting or creating a folder with the same method (GetOrCreateFolder)

More probably it's beyond of this project. You can easily use it manually from your app. However, you also can create new issue for suggest this feature. It will be considered later.

@3F 3F closed this as completed Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants