3

I want to create solution with multiple projects.

I think I have three options:

  1. EnvDTE
  2. Microsoft.Build
  3. Manually create *.sln and *.csproj files

I googled but didn't found good examples for 1 and 2 options (I mean how to create solution, add projects, add refereces, add new or existing project items, etc...)

third option, I think, is easier but if there are good options, I don't need to create projects manually.

So my questions are:

Is there any other options to create projects programmatically?

and Which option is better?

Thanks.

Community
  • 1
  • 1
Vano Maisuradze
  • 5,829
  • 6
  • 45
  • 73
  • MSBuild is for compiling solutions, not for creating the actual solution files. Since build typically is a synonym for compile, please edit your post and replace "build" with "create" where appropriate to make it less confusing to read. – Albin Sunnanbo Apr 13 '12 at 09:08
  • What's your purpose? Also, templates are a fourth way. T4 is a fifth. –  Apr 13 '12 at 13:13
  • 1
    @Will When I use WCF, I always create WCF service and client manually. But it's a tedious task. So I'm trying to automate this process (Adding Services, contracts, Service functions and client code generation) http://www.code-magazine.com/article.aspx?quickid=0809101&page=1 – Vano Maisuradze Apr 13 '12 at 15:09
  • 1
    @VanoMaisuradze: I'd suggest a template, and add some T4 templates to generate the boilerplate client code based on the service contract. –  Apr 13 '12 at 15:25
  • @Will I'll try T4 templates. Thank you for your suggestion. – Vano Maisuradze Apr 13 '12 at 15:41
  • I haven't tried it but check this out: https://github.com/chucknorris/warmup/wiki – 8DH Apr 20 '12 at 06:21
  • any final solution with full source code sample ? – Kiquenet Oct 18 '12 at 09:46
  • @Vano Maisuradze...did you ever find a solution for this? I am trying to accomplish the exact same thing and the research is painful. – dinotom Sep 04 '16 at 13:22

1 Answers1

2

Just manually create the sln and csproj files (and other required files) manually, the formats are very simple. You can make this an easy task by creating a new solution with two projects in Visual Studio, and just inspecting the contents of the sln and csproj files. The idea here is that you are just making yourself a template.

David Anderson
  • 13,558
  • 5
  • 50
  • 76