Configuration of Visual Studio csproj

Is there any way to customize the generation of the .csproj file for VisualStudio?
I need to customize my project configuration, but Unity is always rewriting the file from scratch and overwriting my local changes.

It would also help me if the internal compile event would be exposed to an editor class, such that I could automatically build my own .csproj file on each compilation (or any other project/hierarchy change event).

Any ideas about that? Googled a bit but couldn’t find any good solution.

Thomas

It’s been a while but I thought answering this post might help some people, who need more control over the visual studio project. To create a vs proj is not big deal, but the key point is: How to automatically generate it when you remove or create files in unity?

Answer: Hook into the OnPostProcessAllAssets Editor function of the AssetProcessor class.

`
class PostBuildEventController : AssetPostprocessor
{
    private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        //here call your .csproj generation code
    }
}
`

After that I just parse the Asset directory like:

var di = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "Assets"));
FileInfo[] fis = di.GetFiles("*.cs", SearchOption.AllDirectories);

and construct a .csproj file that I include in my custom solution.
That way I have full control over all project settings, included file types, error/warnings settings etc.

If somebody needs more details, just ask :slight_smile: