开发者

Creating .sln/vcproj files

I would like to write a program开发者_JS百科 or script that would generate .vcproj and .sln files for me. I currently have a lot of settings/configurations that I need to set for every .vcproj I create and I have seen people be able to generate these files some how, although I can not find a good resource through msdn or bing to do so. Could someone please post a link to a resource or perhaps a guide on how to achieve this?


You can generate .sln/.vcproj with MSVS object model. It can be macros or add-in. This sample is a macros to generate .sln/.vcproj.

Sub SlnVcprojGenerator()
    Dim sln As Solution
    Dim prj As Project
    sln = DTE.Solution
    sln.Create("C:\test", "new_sln.sln")
    prj = sln.AddFromTemplate("C:\Program Files (x86)\Microsoft Visual Studio 8\VC\VCWizards\default.vcproj", "c:\test", "new_prj", True)
    sln.SaveAs("C:\test\new_sln.sln")
End Sub


From what I've seen/used, CMake is pretty useful for generating project/solution files.


We create csproj files from script, but we did it just by inspecting the xml and copying. We do get warnings each time we open the manually generated project files though. We can get around that by adding entries to a registry entry somewhere.

I suppose with enough work you could mimic whatever portion of the csproj/vcproj that makes it "official".


Why don't you create project or item templates? http://msdn.microsoft.com/en-us/magazine/cc188697.aspx

You can even export a template from a given project, like explained here: http://msdn.microsoft.com/en-us/library/xkh1wxd8%28v=VS.100%29.aspx. Though this option is actually not available yet for VC++ in VS, there is an add-on, built by the Visual Studio Platform Team, available on the Visual Studio Gallery http://visualstudiogallery.msdn.microsoft.com/57320b20-34a2-42e4-b97e-e615c71aca24/. It enables the same functionality for VC++.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜