1

如何动态生成 Visual Studio 解决方案和项目文件?就像./configure脚本所做的那样。可以接受参数。例如:在 MyProject.sln.template

#if VS_2012
Microsoft Visual Studio Solution File, Format 12.00
#elseif VS_2010
Microsoft Visual Studio Solution File, Format 11.00
#elseif VS_2008
Microsoft Visual Studio Solution File, Format 10.00
#endif
#if VS_2012
Project("{12345678-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcproj", "{98765432-E41A-4C56-B16F-263D2C6D6475}"
EndProject
#endif

我应该使用什么工具?但我不想使用./configure脚本。这些工具最好适用于任何类型的文本文件。因为我有其他类型的文件要生成,而不仅仅是解决方案/项目文件。

4

2 回答 2

0

You can consider cmake which generates workspaces/projects from a config script. Cmake is actually very powerful to maintain platform-independent build scripts. But it will suit your need.

Another option is a home-grown tool to create the sln/vcproj files. They are ultimately XML. There is probably no written documentation but you could reverse engineer from an existing workspace.

于 2012-09-18T08:29:09.317 回答
0

我在 github Nager.TemplateBuilder上找到了这个解决方案。

此示例使用两个 nuget 包创建一个 Windows 桌面应用程序

//Configure Project
var demoProject = new ProjectInfo($"DemoProject", ProjectTemplate.WindowsClassicDesktopWindowsFormsApp);
demoProject.NugetPackages = new List<string> { "System.ServiceModel.NetTcp", "System.Runtime.Serialization.Xml" };

//Configure Solution
var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var solutionInfo = new SolutionInfo("Test", folder);
solutionInfo.ProjectInfos.Add(demoProject);

//Start building machine
var buildingMachine = new SolutionBuildingMachine();
buildingMachine.Build(solutionInfo);
buildingMachine.Dispose();
于 2017-07-24T22:07:15.687 回答