كيفية القيام بما يلي: بنية تكوينات بناء الحل و مشروع
Visual Studioيقدم auإلىmation طراز الكائنات التي تتيح لك إلى الحل عنصر التحكم ومشروع إنشاء التكوينات. تكوين بنية حل يحدد كيفية مشاريع معينة في أحد الحلول إلى تكون مضمنة و، تمكين النشر. التكوينات البنية، المبينة في من الصفحات الخصائص للمشروع للمشروع صندوق حوار، قائمة بناء الجميع الأنواع المتوفرة من المشروع، مثل التصحيح أو الإصدار والأنظمة الأساسية المتوفرة، مثل.NET أو Win32. لكل تركيبة من البنية والنظام الأساسي، هناك هو تكوين مشروع — التعيين من الإعدادات والخصائص المعرفة للمشروع.
الحل بنية الكائنات التكوين:
اسم الكائن |
الوصف |
---|---|
SolutionBuild2كائن |
يستخدم إلى بناء وتنظيف وتوزيعها في تكوين حل نشط حاليا. |
قائمة بالمشاريع والتكوينات التي تمثل إلى يتم إنشاؤها. |
|
SolutionConfigurationsمجموعة |
يحتوي على الجميع المعرفة SolutionConfigurationالكائنات. |
SolutionContextكائن |
يمثل تكوين مشروع's في SolutionConfigurationالكائن. |
SolutionContextsمجموعة |
يحتوي على الجميع SolutionContextعلى الكائنات في SolutionConfigurationالكائن. |
BuildDependencyكائن |
يمثل أحد المشاريع التي يجب أن يتم إنشاؤها قبل أن يتم بناء مشروع owning. |
BuildDependenciesمجموعة |
يحتوي على الجميع مشاريع التي يجب أن يتم إنشاؤها قبل أن يتم بناء مشروع owning. |
مشروع بنية الكائنات التكوين:
اسم الكائن |
الوصف |
---|---|
يمثل بنية تكوين والأنظمة الأساسية. |
|
Configurationكائن |
يمثل تكوين، أو التعيين من بنية الإعدادات، ضمن نظام أساسي معين. |
Configurationsمجموعة |
يحتوي على الجميع Configurationالكائنات. |
OutputGroupكائن |
يحتوي على الملفات التي تم إنشاؤها بواسطة مشروع. |
OutputGroupsمجموعة |
يحتوي على الجميع OutputGroupالكائنات. |
يمكنك باستخدام هذه الكائنات:
إنشاء، إضافة مشاريع للتنشيط، ثم قم بحذف التكوينات الحل.
بنية أو تشغيل أو توزيع أي مشروع في الحل تكوين.
الحصول على معلومات حول الكائنات الموجودة في مشروع أو تكوين الحل.
إضافة أو إزالة أو يحصل معلومات حول تبعيات بناء مشروع.
ملاحظة
قد تختلف مربعات الحوار وأوامر القائمة التى تشاهدها الان عن تلك الموصوفة في التعليمات اعتماداً على الإعدادات النشطة أو الإصدار الخاص بك. تم تطوير هذه الإجراءات من خلال "إعدادات تطوير عام" النشط. To change your settings, choose Import and Export Settings on the Tools menu. لمزيد من المعلومات، راجع العمل مع إعدادات.
مثال
Public Sub OnConnection(ByVal application As Object, ByVal _
connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
SConfig(_applicationObject)
End Sub
Sub SConfig(ByVal dte As DTE2)
Dim SB As SolutionBuild2 = _
CType(_applicationObject.Solution.SolutionBuild, _
SolutionBuild2)
Dim SolCtx As SolutionContext
Dim Proj As Project
Dim CM As ConfigurationManager
Dim Cfgs As SolutionConfigurations
Dim Cfg As SolutionConfiguration2
Dim msg As String
' Get a reference to the solution configurations
' solution context of the first project.
SolCtx = SB.SolutionConfigurations.Item(1).SolutionContexts.Item(1)
CM = _applicationObject.Solution.Projects. _
Item(1).ConfigurationManager
Proj = _applicationObject.Solution.Projects.Item(1)
Cfgs = _applicationObject.Solution.SolutionBuild. _
SolutionConfigurations
Cfg = CType(Cfgs.Item(1), SolutionConfiguration2)
' List the current solution build info.
msg = "BuildState = "
Select Case SB.BuildState
Case vsBuildState.vsBuildStateNotStarted
msg = msg & "Build has not yet started." & vbCr
Case vsBuildState.vsBuildStateInProgress
msg = msg & "Build is in progress." & vbCr
Case vsBuildState.vsBuildStateDone
msg = msg & "Build has completed." & vbCr
End Select
msg = msg & "Configuration Name = " & SolCtx.ConfigurationName _
& vbCr
msg = msg & "Platform Name = " & SolCtx.PlatformName & vbCr
msg = msg & "Project Name = " & SolCtx.ProjectName & vbCr
MsgBox(msg)
' List the current solution configurations.
msg = ("Configuration names are:" & vbCr)
For Each Cfg In Cfgs
msg = msg & Cfg.Name & vbCr
Next
MsgBox(msg)
' Add a new solution configuration.
Cfgs.Add("ANewConfiguration", "Debug", False)
MsgBox(Cfgs.Item(1).Name)
' Create a new project build configuration based on the Debug
' configuration.
Proj.ConfigurationManager.AddConfigurationRow("MyNewConfig", _
"Debug", True)
' Build the solution configuration.
sb.SolutionConfigurations.Item("MyConfig").Activate()
sb.Build()
End Sub
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
SConfig(_applicationObject);
}
public void SConfig(DTE2 dte)
{
try
{
SolutionBuild2 SB =
(SolutionBuild2)_applicationObject.Solution.SolutionBuild;
SolutionContext SolCtx;
Project Proj;
ConfigurationManager CM;
SolutionConfigurations Cfgs;
SolutionConfiguration2 Cfg;
String msg;
// Get a reference to the solution configurations
// solution context of the first project.
SolCtx = SB.SolutionConfigurations.Item(1).
SolutionContexts.Item(1);
CM = dte.Solution.Projects.Item(1).ConfigurationManager;
Proj = _applicationObject.Solution.Projects.Item(1);
Cfgs = _applicationObject.Solution.
SolutionBuild.SolutionConfigurations;
Cfg = (SolutionConfiguration2)Cfgs.Item(1);
// List the current solution build info.
msg = "BuildState = ";
switch (SB.BuildState)
{
case vsBuildState.vsBuildStateNotStarted:
msg = (msg + "Build has not yet started." + "\n");
break;
case vsBuildState.vsBuildStateInProgress:
msg = (msg + "Build is in progress." + "\n");
break;
case vsBuildState.vsBuildStateDone:
msg = (msg + "Build has completed." + "\n");
break;
}
msg = msg + "Configuration Name = " +
SolCtx.ConfigurationName + "\n";
msg = msg + "Platform Name = " + SolCtx.PlatformName + "\n";
msg = msg + "Project Name = " + SolCtx.ProjectName + "\n";
MessageBox.Show(msg);
// List the current solution configurations.
msg = "Configuration names are:" + "\n";
foreach(SolutionConfiguration2 tempConfigs in Cfgs)
{
msg = msg + tempConfigs.Name + "\n";
}
MessageBox.Show(msg);
// Add a new solution configuration.
Cfgs.Add("ANewConfiguration", "Debug", false);
MessageBox.Show
("The name of the first solution configuration item is: "
+ Cfgs.Item(1).Name);
// Create a new project build configuration based on the
// Debug configuration.
Proj.ConfigurationManager.AddConfigurationRow
("MyNewConfig", "Debug", true);
// Build the debug solution configuration.
MessageBox.Show("Build the solution in the debug mode...");
SB.SolutionConfigurations.Item("Debug").Activate();
SB.Build(true);
}
catch (Exception ex)
{
MessageBox.Show("Exception: " + ex);
}
}
التحويل البرمجي للتعليمات البرمجية
لترجمة هذه تعليمات برمجية، قم بإنشاء جديد Visual Studioإضافة-في المشروع واستبدال رمز الفئة يعيّن.cs أو يعيّن.vb مع تعليمات برمجية الموجودة في المثال. قبل تشغيل الوظيفة الإضافية، قم بفتح مشروع في Visual StudioIDE. لمزيد من المعلومات حول كيفية إلى تشغيل وظيفة الإضافية "، راجع كيفية القيام بما يلي: عنصر تحكم إضافة الإضافية باستخدام إدارة زر 'Ins' الإضافية.
راجع أيضًا:
المهام
كيفية القيام بما يلي: إضافة ومعالجة الأوامر
كيفية القيام بما يلي: قم بإنشاء إضافة-في
الإرشادات التفصيلية: إنشاء معالج
المبادئ
مقدمة إلى حلول, مشاريع, و عناصر