Logo
Toggle Menu
  • home
  • blog
  • about
    • about this site
    • contact
    • privacy policy
  • cinema 4d
    • plugins
    • creating c4d plugins
    • plugin cookbook
    • software
  • models
    • nodes
    • plants 1
    • other models - 1
    • other models - 2
  • osl
    • writing osl shaders
    • osl shaders for download

Using GIT in VS 2022

The new plugin build system and Git

I like to use Git as version control for the plugins I write. The main reasons for this are twofold: to start a different branch if I want to try something different to the rest of the plugin, and (more commonly) to make abandoning changes and going back to a previous version much easier. But I found a potential problem when using Git with Visual Studio 2022 and the new build system in the Cinema SDK for R2025.2 and later.

If you refer to my original article on this, you see that if you follow that sequence of actions, you end up with source code in one directory tree and the actual build in a different directory tree. This means that the source code is not in the same folder tree where the solution (.sln) file is located and where the plugin is actually built.

This image from the earlier article shows what I mean:

Now, this doesn't matter at all to VS, which copes just fine with the separate folder trees. But suppose I want to use Git with a project. I'll call the project 'MyPlugin' and it will have three sub-folders, 'project', 'source' and 'res' within the MyPlugin folder, as usual. When I run CMake, I will create a separate build folder named '_build_MyPlugin' as laid out in the main article.

In VS, I'd now like to create a local Git repository, so I choose 'Create Git Repository...' from the Git menu in VS and this is the dialog which appears:

Creating a local Git repo in the build folder

You can see that VS wants to create the repo in the build folder, which seems entirely reasonable, and if I do that, the build folder '_build_MyPlugin' will now contain a .git folder where the repo is held.

The problem

So far, so good, but...any changes I make to the source code, which is in a different folder tree, are not added to the commit list for Git. Although VS knows about the two separate folder trees, it hasn't handled this correctly when it comes to Git. The logical action would be to delete the repo then recreate it in the folder where the source is located, which would give this folder tree:

Source folder tree after creating a Git repo

However, back in VS, this has led to a significant problem. In this image, you see on the left the Visual Studio Solution Explorer window when the repo is in the build folder, and on the right when the repo is in the source folder:

VS solution explorer when Git repo is in different locations

You can see that now, the solution explorer just displays a simple folder view, not the view complete with frameworks, project settings and so on. This is not so good, because you can no longer access the other properties of the project, and the Solution Explorer is just a window into the project folder. In addition, from the VS File menu, 'Close Solution' becomes 'Close Folder' implying a fundamental difference in how VS sees the solution (or even if it sees a solution at all). It seems that VS is smart enough to handle separate project and build directories, but not smart enough to create a Git repo in the desired location and manage it accordingly.

The solution

There are two possible solutions. One is to manage the repo outside VS, either using the command line (yuck!) or one of the many Git GUI front-ends such as GitKraken, SourceTree, etc. This works fine because VS now thinks you aren't using Git and the separate build/project folder trees are handled correctly. Unfortunately this does away with the convenience of managing the repo within VS. If that is important to you (it is to me) then the alternative is not to use separate build and project folder trees at all. When you run CMake, instead of letting it create a separate build folder, point it to the main project folder. Then you get a structure like this (this is the full structure after creating a repo and doing a build):

Plugin source folder after using it for the build folder as well

This means that when creating a Git repo, VS will use the build folder location and since the source and resource files are in the same place, changes to the source are managed correctly. The only downside is that you will need to add a few more files and folders to your .gitignore file, since you don't want all the various build files and folders to be added to any commits.

Page last update December 26th 2025

Blog articles

Using GIT in VS 2022 (December 26th 2025)

Handling missing plugins (December 12th 2025)

Plugin compatibility with R2026 (November 24th 2025)

Affinity is now free! (November 3rd 2025)

World Creator 2025.1 (October 10th 2025)

So that was Cinema R2026? (September 19th 2025)

How to browse 3D assets (August 24th 2025)

Using Unity assets in Cinema 4D (August 15th 2025)

Plant Factory->Cinema 4D->World Creator (August 12th 2025)

Viewing glTF files (August 9th 2025)

Tessellation part 2 (August 5th 2025)

Shader writing with OSL - 3 (July 11th 2025)

Tessellation (June 23rd 2025)

Creating plants for C4D (June 15th 2025)

Adobe alternatives (May 28th 2025)

Using Graswald assets in C4D (May 7th 2025)

Which Mac for plugin development? (May 3rd 2025)

Why do plugin writers do it? (April 11th 2025)

Updating StarScape (February 26th 2025)

Using Cinema 4D shaders in Redshift (January 31st 2025)

PHP and MySQL (December 19th 2024)

Shader writing with OSL - 2 (November 11th 2024)

Shader writing with OSL (October 29th 2024)

StarScape (September 25th 2024)

Converting plugins from C4D 2024 to 2025 (September 16th 2024)

Cinema 4D 2025 and macOS plugins (September 15th 2025)

© 2021-2025 Microbion. All Rights Reserved.