Generate .sln/.csproj without Visual Studio

Hi there!

I’ve been using VS Code for more than a year now but I used to also have Visual Studio installed, which I don’t do on all computers anymore.
I realised recently (by making new projects) that if VS Code is selected as the preferred editor for Unity, no sln/csproj will be generated, even using the Edit → Open C# Project action.

Only way to get them to be generated is to switch the preferred editor to Visual Studio and to use the Open C# Project action or to double click a C# file in the project.
I can deal with that (eventhough it’s quite annoying…) but I would love to not have to install Visual Studio everywhere. I always have the build tools installed (for C++ reasons, but I still install msbuild and .NET for C# anyway) but I don’t really want to install Visual Studio while I am not using it.

Is there any alternative to generate the solution files please ? I need them for Omnisharp (in VS Code) to enable Intellisense.

Thanks!

PS: I’m on Windows, in case it matters.

1 Like

Generate the solution files on the machine with Visual Studio. Then submit those solution/proj files to whatever version control/repository system you use for you shared project. And the other machines will get it, while not needing Visual Studio.

Thank you but, clearly we are not facing the wall with this problem and we are already using this alternative.
However it still is annoying when someone has to create a new project on a computer without VS.

I am only looking for a way to generate these files without VS on the computer or at least without having to switch the preferred editor in the Preferences.

1 Like

Bumping that up as I didn’t get any reply.
I want to be able to generate the csprojs file without switching to Visual Studio for that.

I’m going to write some tool to do it, but if there is a way to do it from the engine, it would be great. Or, if there is some specification for me as to which file types I need to include for it to be similar to Unity’s (I’ve seen it include .cs, .shader, .compute but unsure what else!)
It would also help to be able to regenerate them easily on the fly so that when people add files to the project they can regenerate their csproj themselves : )

Thanks,

Clem

1 Like

Same here. No *.sln; *.csproj files generation in latest Unity version, which is critical for Sublime Text users. I cannot find any solution except manual switching to VS, building, and switching back to ST. That is terrible :frowning:

1 Like

Agreed. I’ve been struggling to keep sublime text 3 as my default editor, but it just gets harder and harder. I’ve had to resort to jumping back and forth to VS to generate the .sln files and it’s really a huge pain. VS eats resources on my machine like nobody’s business, I really wish I didn’t have to rely on it.

2 Likes

What worked for me was Edit → Preferences → External Tools, and I set VSCode up here by “Browse…”-ing the VSCode executable.
As soon as it’s set, sln and project files are generated, OmniSharp is loaded up, etc, so everything works like charm (beforehand, with ‘open by file extension’ setting, even though VS Code started as the script editor, the sln and project files were not created by Unity).

Hope this helps.

1 Like

@rad1c Thanks but eventhough it used to work for me before 2018, it doesn’t anymore. I definitely have it set as my code editor in Unity, it opens the files correctly, on the correct line, but it won’t create any project file : (

@LitchiSzu
Huhh. Weird. Are you sure the setting is correct? Here’s how it looks like for me:


It didn’t work for me either until I explicitly pointed to vscode’s exe file (see Script editor is “named”).
If it looks like that for you, you could try pointing at the exe again maybe?

@rad1c Yes, 100% sure, but I now know what the problem was.
Unity, for some (really bad) reasons, decides to generate the sln and project files depending on the name of the code editor set in preferences. And it assumes (wrongly) that if you are not using something from their list, you don’t want sln files.
Problem is that, I was using VSCode Insiders and the executable name is not what Unity expects. Renaming the exe to code.exe fixes the problem.

So guys, if you need sln files for Omnisharp with anything, just rename your executable to code.exe!
Yes it’s a really dodgy work around.

I made this suggestion that you can upvote to hopefully have something better:
https://feedback.unity3d.com/suggestions/option-to-let-user-generate-solution-and-project-files

4 Likes

Yep, it works. Unfortunately, Unity disable custom command line arguments for external editor (code.exe) and because of this on each appeal to a script from logs window Sublime Text open new window instead of using the existing one :frowning:
Stupid bug, hate it.

Love you bro you don’t know how much I google this shit going even up to the second page.

This is the right way to do it.
Thank you.

Since, I don’t know when you can simply go to Edit → Preferences → External tools and select everything under “Generate .csproj files for:” and just clic on Regenerate project files. ;p that worked for me after testing it out!