Do I have to "gitignore" sln(Visual Studio Solution) file?

Hi, I have added a PlayerControllerClass using UE4.15 and 4.16 with VS15 and VS17 from my 64-bit Windows machine.

So the following files were created.

MyProject\Intermediate\ProjectFiles\MyProject.vcxproj
MyProject\Intermediate\ProjectFiles\MyProject.vcxproj.filters

MyProject\Source\MyProject.Target.cs

MyProject\Source\MyProject\MyPlayerController.cpp
MyProject\Source\MyProject\MyPlayerController.h
MyProject\Source\MyProject\MyProject.cpp
MyProject\Source\MyProject\MyProject.h
MyProject\Source\MyProject\MyProject.Build.cs

MyProject\MyProject.sln

Since UE4.vcxproj and MyProject.vcxproj exist, I think I need the MyProject.sln file for my CI(Continuous Integration) tool.

I use Atlassian’s Bamboo 6 for my CI tool. This can peform a MSBuild15 task after a commit is pushed to the remote repository.

By referring the “Building without Visual Studio” article, I was planning to use MSBuild15 to build UE4 game projects.

I use GitHub Desktop 3 for my Git GUI client and this provides a .gitignore file template for Unreal 4 projects.

However, this file template ignores the sln files. You can check the template by viewing the attached file.

GitIgnore.txt

GitAttribute.txt

Is there a reason for ignoring the sln file?

Also, if I want to build the UE4 game projects with the CI tool, I should not ignore the sln file, right?

Lastly, just as described in the “Building without Visual Studio” article, can I build my game project using MSbuild without using UE4 editor or Visual Studio IDE?

I wish to double check about this.

-Best Regards

1 Like

##Do I have to “gitignore” sln file?
To answer your headline question, the answer is “no, you don’t.”

It’s good practice however to ignore the solution file. The solution file and all the project files in the Intermediate directory, are generated from your .uproject file. There’s therefore no need not to ignore these files; in fact not including them in your ignore list could cause problems. Many source control systems perform their synchronisation with the repository placing read only files on the local storage medium. This can result in build errors using some tools as they refuse to modify the files if the RO flag is set on the file attributes.

##I think I need the sln file for my CI?
It depends the way you want to set up your CI. If you want to provide a solution (.sln) file to your CI and then tell it to build that, of course you’d need the .sln file. However in UE4, it’s standard practice to simply tell UnrealBuildTool to build the .uproject file. Any required intermediate files will be generated as part of the build process; it doesn’t even generate a .sln file for this process - everything’s taken care of internally.

Someone’s already answered a question on how to build using the UBT command line here:
https://answers.unrealengine.com/questions/26160/proper-way-of-using-unrealbuildtoolexe-from-the-co.html

##Can I build my game using MSbuild?
Of course you can always use an MSBuild command line option with Visual Studio, avoiding the use of the IDE. If you have a sln file this is well documented. However as I point out above, this might be considered slightly non-standard practice for command line UE4 builds.

Final thoughts

I’ve never used Atlassian Bamboo (TeamCity’s always supported our needs and it’s free for small teams) - but I’m quite sure it will have a command line build configuration option. I’d recommend using this and making a call to unreal build tool as shown how to in the link provided. Forget your solution file, leave it on your gitignore.

1 Like