test/Misc/EFTools/TestInfrastructure/VS/DteExtensions.cs
/// <summary>
///     Create a new project using specified info
/// </summary>
/// <param name="dte">dte instance</param>
/// <param name="projectName">project name</param>
/// <param name="kind">project kind</param>
/// <param name="language">project language</param>
/// <returns>new created project</returns>
Create a new project using specified info
Create a new project using specified info
public static Project CreateProject(
            this DTE dte, string solutionPath, string projectName, ProjectKind kind, ProjectLanguage language)
        {
            Debug.Assert(dte != null, "CreateProject: Dte is null");
            Debug.Assert(!string.IsNullOrEmpty(solutionPath), "!string.IsNullOrEmpty(solutionPath)");
            Debug.Assert(!string.IsNullOrEmpty(projectName), "!string.IsNullOrEmpty(projectName)");
            Debug.Assert(dte.Solution != null, "CreateProject: dte.Solution must be created by adding project");
            var template = GetProjectTemplate(dte, kind, language);
            var projectDir = Path.Combine(solutionPath, projectName);
            if (Directory.Exists(projectDir))
            {
                Directory.Delete(projectDir, true);
            }
            dte.Solution.AddFromTemplate(template, Path.Combine(solutionPath, projectName), projectName, false);
            foreach (Project project in dte.Solution.Projects)
            {
                if (project.Name.Contains(projectName)) 
                {
                    return project;
                }
            }
            Debug.Fail("There is no new project created.");
            return null;
        }
public static Project CreateProject ( this DTE dte , string solutionPath , string projectName , ProjectKind kind , ProjectLanguage language ) { Debug . Assert ( dte != null , " " ) ; Debug . Assert ( ! string . IsNullOrEmpty ( solutionPath ) , " " ) ; Debug . Assert ( ! string . IsNullOrEmpty ( projectName ) , " " ) ; Debug . Assert ( dte . Solution != null , " " ) ; var template = GetProjectTemplate ( dte , kind , language ) ; var projectDir = Path . Combine ( solutionPath , projectName ) ; if ( Directory . Exists ( projectDir ) ) { Directory . Delete ( projectDir , true ) ; } dte . Solution . AddFromTemplate ( template , Path . Combine ( solutionPath , projectName ) , projectName , false ) ; foreach ( Project project in dte . Solution . Projects ) { if ( project . Name . Contains ( projectName ) ) { return project ; } } Debug . Fail ( " " ) ; return null ; }
Create a new project using specified info
Create a new project using specified info
// Check if the project directory exists delete it does since AddFromTemplate will throw if the directory exists. // Venus projects Name is the full path name - so need to use Contains()
new created project
new created project
DTE
this
solutionPath
string
projectName
string
None
kind
ProjectKind
None
language
ProjectLanguage
None
dte
None