BuildDependency.RemoveProject, méthode
Supprime un projet de la liste spécifiant l'ordre de génération des projets.
Espace de noms : EnvDTE
Assembly : EnvDTE (dans EnvDTE.dll)
Syntaxe
'Déclaration
Sub RemoveProject ( _
ProjectUniqueName As String _
)
void RemoveProject(
string ProjectUniqueName
)
void RemoveProject(
String^ ProjectUniqueName
)
abstract RemoveProject :
ProjectUniqueName:string -> unit
function RemoveProject(
ProjectUniqueName : String
)
Paramètres
ProjectUniqueName
Type : StringObligatoire. Nom du projet issu de la propriété UniqueName à ajouter en tant que dépendance.
Exemples
Cet exemple fonctionne uniquement dans Visual Studio .NET 2003. Pour plus d'informations, consultez Migrating Code that Creates Projects by Using Templates.
Sub RemoveProjectExample(ByVal dte As DTE)
' Create a new solution.
Dim soln As Solution = dte.Solution
Dim solnName As String = "NewSolution.sln"
Dim tempPath As String = System.IO.Path.GetTempPath()
soln.Create(tempPath, solnName)
' Create two new Visual Basic Console Application projects.
Dim templatePath As String = <template path>
templatePath &= "ConsoleApplication.vsz"
Dim projName As String = "Project1"
soln.AddFromTemplate(templatePath, tempPath & projName, projName)
Dim proj1 As Project = soln.Item(1)
projName = "Project2"
soln.AddFromTemplate(templatePath, tempPath & projName, projName)
Dim proj2 As Project = soln.Item(2)
' Make Project1 dependent on Project2.
Dim bd As BuildDependency = _
soln.SolutionBuild.BuildDependencies.Item(proj1.UniqueName)
bd.AddProject(proj2.UniqueName)
' Enumerate Project1's dependencies.
Dim depends As String = ""
Dim proj As Project
For Each proj In CType(bd.RequiredProjects, Array)
depends &= proj.Name & vbCrLf
Next
MsgBox(bd.Project.Name & " has the following dependencies:" & _
vbCrLf & vbCrLf & depends)
If MsgBox("Remove dependency on " & proj2.Name & " from " & _
bd.Project.Name & "?", MsgBoxStyle.YesNo) = _
MsgBoxResult.Yes Then
bd.RemoveProject(proj2.UniqueName)
' Enumerate Project1's dependencies.
depends = ""
For Each proj In CType(bd.RequiredProjects, Array)
depends &= proj.Name & vbCrLf
Next
MsgBox(bd.Project.Name & " has the following dependencies:" & _
vbCrLf & vbCrLf & depends)
End If
End Sub
public void RemoveProjectExample(DTE dte)
{
// Create a new solution.
Solution soln = dte.Solution;
string solnName = "NewSolution.sln";
string tempPath = System.IO.Path.GetTempPath();
soln.Create(tempPath, solnName);
// Create two new C# Console Application projects.
string templatePath = <template path>;
templatePath += "CSharpConsole.vsz";
string projName = "Project1";
soln.AddFromTemplate(templatePath, tempPath + projName,
projName, false);
Project proj1 = soln.Item(1);
projName = "Project2";
soln.AddFromTemplate(templatePath, tempPath + projName,
projName, false);
Project proj2 = soln.Item(2);
// Make Project1 dependent on Project2.
BuildDependency bd =
soln.SolutionBuild.BuildDependencies.Item(proj1.UniqueName);
bd.AddProject(proj2.UniqueName);
// Enumerate Project1's dependencies.
string depends = "";
foreach (Project proj in (Array)bd.RequiredProjects)
{
depends += proj.Name + Environment.NewLine;
}
MessageBox.Show(bd.Project.Name +
" has the following dependencies:" + Environment.NewLine +
Environment.NewLine + depends);
if (MessageBox.Show("Remove dependency on " + proj2.Name +
" from " + bd.Project.Name + "?", "",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
bd.RemoveProject(proj2.UniqueName);
// Enumerate Project1's dependencies.
depends = "";
foreach (Project proj in (Array)bd.RequiredProjects)
{
depends += proj.Name + Environment.NewLine;
}
MessageBox.Show(bd.Project.Name +
" has the following dependencies:" + Environment.NewLine +
Environment.NewLine + depends);
}
}
Sécurité .NET Framework
- Confiance totale accordée à l'appelant immédiat. Ce membre ne peut pas être utilisé par du code d'un niveau de confiance partiel. Pour plus d'informations, voir Utilisation de bibliothèques à partir de code d'un niveau de confiance partiel.
Voir aussi
Référence
Autres ressources
Comment : compiler et exécuter les exemples de code du modèle objet Automation