Where is the extensions filter of Visual Studio Tools

Hi,

back in Unity 5.1 with the Visual Studio Tools plugin I could add custom file extensions, which then are added to the solution file and I could see them in Visual Studios solution explorer.

See this screenshot:
61518-old-config-options.png

I added there XSD and proto files and handled them easily in Visual Studio, but after the upgrade to 5.3.1 the files are excluded again from the solution and I can’t find this option anymore.

Does anyone know where to find the option in Unity 5.3.1?

Edit:
Since Unity 5.2, this option is available under Edit → Project Settings → Editor.

Original:
Ok, it seems that this option doesn’t exists anymore in the UI. But you can still access it in an editor script, like the VSTU Project File Generation API suggests.

For a quick solution for my problem see the editor script under this answer. The only gotcha of this is, that the editor script won’t work if you haven’t installed the Visual Studio Tools. This means that our artists and mac users couldn’t compile the project anymore -.-

Probably this can be fixed with some reflection magic, but for now this is a working solution for us coders working with Windows and Visual Studio, we will just not commit this file :smiley:

// See: http://unityvs.com/documentation/api/project-file-generation/
[InitializeOnLoad]
public class VisualStudioSolutionExtender
{
    private static readonly string[] FILE_EXTENSIONS_TO_INCLUDE = {"*.proto", "*.xsd"};
    
    [MenuItem("Visual Studio Tools/Regenerate Project Files", false, 0)]
    public static void Regenerate()
    {
        SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.GenerateProject();
    }
    
    static VisualStudioSolutionExtender()
    {
        SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilesGenerator.ProjectFileGeneration += ModifyProjectFile;
    }
    
    private static string ModifyProjectFile(string name, string content)
    {
        bool isEditorProject = name.EndsWith("CSharp.Editor.csproj");
        
        var document = XDocument.Parse(content);
        var defaultNs = document.Root.GetDefaultNamespace();
        
        // The csproj file contains multiple <ItemGroup> entries: One containing assemblies, one with cs code files
        // and one with none-code files. The last one is represented with <None ... /> entries and we need to find
        // these.
        // So the XPath essentially searches all "None" nodes (ignoring XML namespaces) which are 3 levels deep
        // and gets their parent.
        var noneCodeItemGroup = document.Root.XPathSelectElement("/*/*/*[local-name()='None']/..");
        
        if (noneCodeItemGroup != null)
        {
            foreach (var ext in FILE_EXTENSIONS_TO_INCLUDE)
            {
                foreach (var file in Directory.GetFiles(Application.dataPath, ext, SearchOption.AllDirectories))
                {
                    // Get rid of the full path, we only need to start in the Assets folder.
                    var pathToAdd = file.Replace(Application.dataPath, "Assets");
                    
                    // Files in any Editor folder should go only into the Editor C# project and files outside of
                    // an Editor folder should only go in the non-Editor C# project.
                    if ((pathToAdd.Contains("Editor\\") && isEditorProject)
                        || (!pathToAdd.Contains("Editor\\") && !isEditorProject))
                    {
                        noneCodeItemGroup.Add(new XElement(defaultNs + "None", new XAttribute("Include", pathToAdd)));
                    }
                }
            }
        }
        
        var str = new Utf8StringWriter();
        document.Save(str);
        return str.ToString();
    }
    
    // necessary for XLinq to save the xml project file in utf8
    private class Utf8StringWriter : StringWriter
    {
        public override Encoding Encoding
        {
            get { return Encoding.UTF8; }
        }
    }
}