0

I am developing a development C# Generator and I need to make a class, but I don't understand how I can make the .csproj files.

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
Polymorphism
  • 375
  • 1
  • 3
  • 11

3 Answers3

2

These are just text files.

cs proj is an msbuild file. And cs file is just a nomale code file.

The best thing to do is to use a sample .csproj and .cs file and use search and replace to put the correct values into it. This will get you started.

When you understand the theory you can move on to a better templating engine such as RAZOR or T4. And then onto the better techniques of generating assemblies at run time.

Community
  • 1
  • 1
Preet Sangha
  • 64,563
  • 18
  • 145
  • 216
0

Create an empty solution and save it in a location. Then add a project to that solution and save the solution to a different place. Open these two solutions with a text editor and compare the files, so you can see how does the solution file change if you add a project to a solution. In the same way, if you want to add a project to that solution programatically just read the solution file using textreader edit the solution file text and write it back to the same solution file.

Hope it helps.

Ozgur Dogus
  • 911
  • 3
  • 14
  • 38
0

Try the following batch code, which requires the dotnet command to be available. This generates your .cs program, .csproj file, bin folder and obj folder.

cd Projects
set /p user_in=Enter the new folder name: 
dotnet new console -o "%user_in%"
cd "%user_in%"
dotnet restore
Doot
  • 555
  • 5
  • 15