Solution3.AddFromTemplate(String, String, String, Boolean) Yöntem

Tanım

Var olan bir proje dosyasını ve bu dosyanın içerdiği tüm öğeleri veya alt dizinleri belirtilen konuma kopyalar ve çözüme ekler.

EnvDTE::Project AddFromTemplate(std::wstring const & FileName, std::wstring const & Destination, std::wstring const & ProjectName, bool Exclusive = false);
[System.Runtime.InteropServices.DispId(15)]
public EnvDTE.Project AddFromTemplate (string FileName, string Destination, string ProjectName, bool Exclusive = false);
[<System.Runtime.InteropServices.DispId(15)>]
abstract member AddFromTemplate : string * string * string * bool -> EnvDTE.Project
Public Function AddFromTemplate (FileName As String, Destination As String, ProjectName As String, Optional Exclusive As Boolean = false) As Project

Parametreler

FileName
String

Gereklidir. Şablon proje dosyasının uzantısına sahip tam yol ve dosya adı.

Destination
String

Gereklidir. Dosya adınıniçeriğini kopyalamak için dizinin tam yolu.

ProjectName
String

Gereklidir. Hedef dizindeki proje dosyasının adı. Bu, uzantıyı içermelidir. Görünen ad, ProjectNameöğesinden türetilir.

Exclusive
Boolean

İsteğe bağlı. Projenin geçerli çözümde mi yoksa kendi içinde mi yükleneceğini belirtir; true geçerli çözüm kapalıysa ve proje yeni bir çözüme eklenirse, false Proje mevcut, açık çözüme eklenirse.

Döndürülenler

Project

Bir Project nesnesi.

Uygulamalar

Öznitelikler

Örnekler

Sub SolutionExample(ByVal dte As DTE2)  
    ' This function creates a solution and adds a Visual C# Console  
    ' project to it.  
    Try  
        Dim soln As Solution3 = CType(DTE.Solution, Solution3)  
        Dim csTemplatePath As String  
        ' This path must exist on your computer.  
        ' Replace <file path> below with an actual path.  
        Dim csPrjPath As String = "<file path>"  
        MsgBox("starting")  
        ' Get the project template path for a C# console project.  
        csTemplatePath = soln.GetProjectTemplate _  
        ("ConsoleApplication.zip", "CSharp")  
        ' Create a new C# Console project using   
        ' the template obtained above.  
        soln.AddFromTemplate(csTemplatePath, csPrjPath, _  
        "New CSharp Console Project", False)  
        MsgBox("done")  
    Catch ex As System.Exception  
        MsgBox(ex.ToString)  
    End Try  
End Sub  
public void SolutionExample(DTE2 dte)  
{  
    // This function creates a solution and adds a Visual C# Console  
    // project to it.  
    try{  
        Solution3 soln = (Solution3)_applicationObject.Solution;  
        String csTemplatePath;  
        // The file path must exist on your computer.  
        // Replace <file path> below with an actual path.  
        String csPrjPath = "<file path>";  
          "<file path>MessageBox.Show("Starting...");  
          "<file path>"<file path>csTemplatePath =   
          soln.GetProjectTemplate("ConsoleApplication.zip", "CSharp");  
        // Create a new C# Console project using the template obtained   
        // above.  
        soln.AddFromTemplate(csTemplatePath, csPrjPath,  
          "New CSharp Console Project", false);  
        MessageBox.Show("Done!");  
    }  
    catch(SystemException ex)  
    {  
        MessageBox.Show("ERROR: " + ex);  
    }  
}  

Açıklamalar

Çözüm Gezgini ' de görünen projenin adı ProjectName dosya uzantısı olmadan. AddFromTemplate hedefte yeni proje dosya adı zaten varsa başarısız olur.

Not

Visual BasicVe Visual C# projeleri için: döndürülen Project nesnenin değeri Nothing veya null . Oluşturulan Project nesneyi, DTE.Solution.Projects ProjectName Yeni oluşturulan projeyi tanımlamak için parametresini kullanarak koleksiyonunu çağırarak bulabilirsiniz.

Şunlara uygulanır