如何以编程方式在 vs 2008 中创建新的空白解决方案?
基于设计的方法是:新项目->其他项目类型 -> Visual Studio 解决方案 ->空白解决方案
我必须在 C# 中以编程方式创建一个空白解决方案,并在此解决方案中添加新的空项目和文件。我在网上找到了很多使用 DTE 的代码,但他们正在现有的解决方案资源管理器中添加我的空项目,因此请给我一些参考代码。
The design based approach is: New Project -> Other Project Type -> Visual Studio Solution -> Blank Solution
I have to create a blank solution programmatically in C# and in this solution add new empty project and files. i found a lot of code on the web using DTE but they are adding my empty project in existing solution explorer so please give me some reference code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 DTE 创建一个新的空白解决方案,如下所示:
您必须添加对 EnvDTE.dll、EnvDTE80.dll 和 EnvDTE90.dll 的引用。您将得到的结果文件非常简单,可以通过其他方式创建(作为纯文本文件)。
You can create a new blank solution using DTE like this:
You have to add references to EnvDTE.dll, EnvDTE80.dll, and EnvDTE90.dll. The resulting file you will get is very simple and could be created in other ways (as a plain text file).
如果您确实只需要使用空项目文件创建解决方案,那么只需编写 .sln 文件(它是纯文本文件)和 .csproj 文件(它是 XML MSBuild 文件)可能会更容易)手动操作比扰乱 Visual Studio 自动化更重要。
If you truly just need to create a solution with an empty project file it's probably much easier to just write the .sln file (it's a plain text file) and the .csproj file (it's an XML MSBuild file) by hand than it is to mess with Visual Studio automation.
手动创建一个带有空项目的解决方案。将项目/解决方案名称/其他特定数据替换为 {n},以便稍后可以使用 string.Format 填充它们。然后将这些文件(sln 和 csproj)嵌入到程序集中并将它们用作资源。
Create a solution with empty project manually. Replace project/solution name/other specific data with {n} so you can fill them using string.Format later. Then embed those files (sln and csproj) to your assembly and use them as resource.