views:

235

answers:

4

Is there any way to write a Visual Studio Project file easy or do i have to look at the xml format and write it by hand? Is there any lib for this in .net framework(3.5)?

Im using vb.net but c# would also work..

A: 

There is no support for this in the framework. The Visual Studio project file format is specific to Visual Studio. There may be support in the MSBuild libraries but you would need to include them as a reference and interact with it that way. What are you trying to do that requires you to create a VS project file?

The link provided here should give you what you need.

Scott Dorman
Added a link to @Mendelt's answer as the link provided should give you what you need.
Scott Dorman
+6  A: 

Visual Studio since version 2005 uses the MSBuild format to store C# and VB project files.

You could read this primer http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=472 or search the Web for further examples.

For programmatic access you could use the classes in the Microsoft.Build.BuildEngine namespace. Probably the Project class is of most interest to you.

0xA3
+1. I'd also like to add that MSBuild format allows for application-specific data to be included (ignored by MSBuild itself) and Visual Studio uses it. You should also check you what Visual Studio actually stores in there.
Vilx-
And also - new application-specific settings sometimes appear too with some updates. For example VS2008 Web Projects got a new one with SP1.
Vilx-
+2  A: 

I haven't tried this myself but you might want to look at http://msdn.microsoft.com/en-us/library/microsoft.build.buildengine.project.aspx

Mendelt
+1  A: 

We do it from a couple of in-house tools. The project files for Visual Studio are stored as XML, so you can just use whatever XML classes you prefer. Make sure you pay attention to GUIDs as they are used to tie everything together between the various files in Visual Studio.

Brian Rasmussen