使用Visual Studio SDK创建项目时,是否可以隐藏生成的窗口?
我目前正在尝试使用C#中的Visual Studio SDK创建一个Visual Studio项目,以下步骤:
- 首先,我使用DTE界面打开Visual Studio,
- 然后创建一个新目录
- ,然后我创建一个解决方案文件,
- 最后我在使用模板的解决方案
以下是下面的代码:
//Load DTE
Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.16.0");
EnvDTE.DTE dte = (EnvDTE.DTE)System.Activator.CreateInstance(t);
//Hide UI
dte.SuppressUI = true;
dte.MainWindow.Visible = false;
//Create new directory
if (Directory.Exists(@"C:\Temp\SolutionFolder"))
Directory.Delete(@"C:\Temp\SolutionFolder", true);
Directory.CreateDirectory(@"C:\Temp\SolutionFolder");
Directory.CreateDirectory(@"C:\Temp\SolutionFolder\SolutionTemp");
//Create solution
dynamic solution = dte.Solution;
solution.Create(@"C:\Temp\SolutionFolder", "SolutionTemp");
solution.SaveAs(@"C:\Temp\SolutionFolder\SolutionTemp\MySolutionTemp.sln");
//Create project with template
string template = @"C:\TwinCAT\3.1\Components\Base\PrjTemplate\TwinCAT Project.tsproj"; //path to project template
dynamic project = solution.AddFromTemplate(template, @"C:\Temp\SolutionFolder\SolutionTemp", "MyTmpProject");
一切正常,但是我在创建项目时出现的窗口下方,但我希望它被隐藏。有人知道如何隐藏“项目创建”窗口?
ps:我正在创建的项目是一个twincat项目( https://www.beckhoff.com/fr-fr/products/automation/automation/twincat/ )是基于Visual Studio的IDE,但没有任何差异。
谢谢,
伊曼纽尔
I am currently trying to create a visual studio project with the visual studio sdk in C# following those steps :
- First I am using the DTE interface to open Visual studio
- Then I create a new directory
- Then I create a solution file
- Finally I create the project in the solution using a template
Here is the code below :
//Load DTE
Type t = System.Type.GetTypeFromProgID("VisualStudio.DTE.16.0");
EnvDTE.DTE dte = (EnvDTE.DTE)System.Activator.CreateInstance(t);
//Hide UI
dte.SuppressUI = true;
dte.MainWindow.Visible = false;
//Create new directory
if (Directory.Exists(@"C:\Temp\SolutionFolder"))
Directory.Delete(@"C:\Temp\SolutionFolder", true);
Directory.CreateDirectory(@"C:\Temp\SolutionFolder");
Directory.CreateDirectory(@"C:\Temp\SolutionFolder\SolutionTemp");
//Create solution
dynamic solution = dte.Solution;
solution.Create(@"C:\Temp\SolutionFolder", "SolutionTemp");
solution.SaveAs(@"C:\Temp\SolutionFolder\SolutionTemp\MySolutionTemp.sln");
//Create project with template
string template = @"C:\TwinCAT\3.1\Components\Base\PrjTemplate\TwinCAT Project.tsproj"; //path to project template
dynamic project = solution.AddFromTemplate(template, @"C:\Temp\SolutionFolder\SolutionTemp", "MyTmpProject");
Everything works fine but I have the window below that appears when i create my project but I want it to be hidden. Does anyone know how to hide the "project creation" window ?
PS : The project I am creating is a Twincat project (https://www.beckhoff.com/fr-fr/products/automation/twincat/) that is an IDE based on visual studio but it doesn't make any differences.
Thanks,
Emmanuel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尝试了以下内容吗?
官方文件说:
在:
Did you tried the following?
The official documentation says:
Check at: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_automationinterface/2489025803.html&id=