I want to change the 'csproj' file of my unity project in order to be able to access a specific library as this answer sugests.
I am manually editing the file but every time i reload the project, the 'csproj' file returns to it's initial state.
Is this a common issue? Is there a way to avoid this and change the file permanently?
EDIT: My goal is to use CSharpCodeProvider so if there is another way of doing it without changing the 'csproj' file, i will gladly adopt the approach
As far as I know, you cannot prevent Unity from overwriting your csproj files upon recompilation of your scripts.
When working with larger code bases and Unity3D I tend to put most of my code into separate .Net assemblies (DLLs). This helps me when I'm sharing code between multiple projects and game servers, and Unity doesn't need to compile all scripts when it detects changes.
To do that fire up your .Net IDE of choice and create a new class library project (which will output a .dll). Make sure it is targeting the .Net Framework 3.5 or lower. Then, you copy the output .dll into you Unity project's Assets folder in a post-build step. I like to use a post-build step to prevent me from forgetting to copy the assembly after a change.
DLLs in the project's Assets folder are automatically referenced by Unity when it creates its C# projects. This means all of the containing code can be used from within your scripts. Note, though, that the other way around will not work as easily: you cannot use code from Unity scripts in your separate project.
Depending on what exactly you want to do with CSharpCodeProvider you can put your generation logic (and the necessary
Import
directive) into such a separate project.Edit: For more information how we set up our project structure you can watch this talk by the lead programmer on Jagged Alliance Online from Unite11.