Create C # project at runtime

Does anyone know how I can create a C # project at runtime, add classes to it, and compile it to create a dll.

+1
source share
2 answers

If you just want to compile the code and generate the dll, see cdhowie's answer.

If you want to have a complete project file at the end, you can create a csproj file through XML or Text output that points to the code (and other) files you want to include, then run the msbuild myproject.csproj command. "

Open the .csproj file for the project that you have with notepad, the structure is not complicated.

+2
source

If you are interested in creating dynamic classes for your own use, see the System.Reflection.Emit namespace. You can create an assembly full of types on the fly.

+1
source

Source: https://habr.com/ru/post/905952/


All Articles