I want to write a wizard in .net which programmatically generates Visual Studio Solution with some projects. I will have a XML file with details of files need to be included in the project with their respective paths to fetch them and a list of project names. Is there any way I can achieve this
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
Check out the Text Template Transformation Toolkit (T4). It's pretty sweet, and powers some of the file generation in ASP.NET MVC. Scott Hanselman's got a great introductory article on the topic.
Well the Visual Studio SDK would be your path to go. There are methods where you can create files and I think also projects based on project templates. So for instance you can create a new "asp.net mvc" project or a class library. You could even create your own template.
I am quite sure that you can do this only inside VS.
Otherwise, there is nothing wrong to generate the project and sln files be generating the xml files, thats one of the good things that they are plain xml in the end. You just need to generate some Projectd Guids, but I think this would be fairly simple and totally "legal".
good progress!
You can do this with a short bit of code or script. Visual Studio will fill in most of the GUIDs for you...
I knocked something like this together as a one-off to collate projects. It's not 100% perfect, you might end up with duplicates from the way the code handles project names. Hopefully it will show you the way.
What we do here is set up the preamble to the Solution file, then insert each solution (you need the Project type guid, seen here beginning FAE, but not the Project's own GUID, which VS will insert on saving the Solution file). There's a bit more boilerplate then we insert the build configuration for each project. I had about 12 configurations for each project (different Release and Debug settings) but I've condensed it here to two.
Head looks a bit like:
But I think there are control characters in the first line - beware!
Tail looks like
We built a tool called Tree Surgeon that does exactly this. Things are under review and discussion to revieve (or ditch it) as times have changed since it was originally created but it does what you're asking here (and is open source).