Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Generate .sln/.csproj without Visual Studio

Discussion in 'Scripting' started by LitchiSzu, May 12, 2018.

  1. LitchiSzu

    LitchiSzu

    Joined:
    May 14, 2016
    Posts:
    17
    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.
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    5,721
    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.
     
  3. LitchiSzu

    LitchiSzu

    Joined:
    May 14, 2016
    Posts:
    17
    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.
     
  4. LitchiSzu

    LitchiSzu

    Joined:
    May 14, 2016
    Posts:
    17
    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
     
  5. Dance_M

    Dance_M

    Joined:
    Aug 17, 2014
    Posts:
    6
    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 :(
     
  6. Jakintosh

    Jakintosh

    Joined:
    Jan 26, 2014
    Posts:
    1
    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.
     
    Dance_M likes this.
  7. rad1c

    rad1c

    Joined:
    Feb 26, 2016
    Posts:
    21
    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.
     
    Last edited: Jul 13, 2018
  8. LitchiSzu

    LitchiSzu

    Joined:
    May 14, 2016
    Posts:
    17
    @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 : (
     
  9. rad1c

    rad1c

    Joined:
    Feb 26, 2016
    Posts:
    21
    @LitchiSzu
    Huhh. Weird. Are you sure the setting is correct? Here's how it looks like for me: setting.jpg

    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?
     
  10. LitchiSzu

    LitchiSzu

    Joined:
    May 14, 2016
    Posts:
    17
    @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
     
    Dance_M likes this.
  11. Dance_M

    Dance_M

    Joined:
    Aug 17, 2014
    Posts:
    6
    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 :(
    Stupid bug, hate it.
     
  12. TKdevlop

    TKdevlop

    Joined:
    Aug 2, 2018
    Posts:
    1
    Love you bro you don't know how much I google this S*** going even up to the second page.