locked
Problem with setting a StartUp project in a Multi-project Template RRS feed

  • Question

  • Hi,

    I have created a Project Template with Multiple projects in it. When i run and create a new project, i am not able to set specific project as a 'Startup Project' by default for my solution.

    How can i make a specific project as my Startup project by default.

    In my roottemplate.Vstemplate file, i have a project collection.

    <TemplateContent>
      <ProjectCollection>
       <ProjectTemplateLink  ProjectName ="Console">Client Script\Client.vstemplate </ProjectTemplateLink>
       <ProjectTemplateLink  ProjectName ="Test">Sample Script\Sample.vstemplate</ProjectTemplateLink>   
      </ProjectCollection>
     </TemplateContent>

     is it possbile to make "Test" project as my Startup Project by default in my output.

    Please suggest.

    Thanks in advance,

    Ravi


    • Edited by chrasa Thursday, December 12, 2013 3:00 PM message change
    Thursday, December 12, 2013 2:59 PM

Answers

All replies

  • We don't have any attribute or element to set the startup project. I think the default behavior for a new solution is for the first project added to the solution to be the startup project.

    However if it's critical to set the startup project, you could resolve the problem by creating a template wizard extension for your templates and using DTE to set the startup project in the Microsoft.VisualStudio.TemplateWizard.IWizard.RunFinished implementation (http://msdn.microsoft.com/en-us/library/ms185301.aspx).

    The DTE call would look something like this:

    DTE.Solution.Properties.Item("StartupProject").Value =  "<projectname>"

    A similar DTE question is here:

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/a3a23781-34ef-4d5f-8233-0adb0ac15d32/dte-set-startup-project?forum=vsx

    Thanks

    Kendagor

    • Proposed as answer by Kendagor Thursday, December 12, 2013 11:31 PM
    Thursday, December 12, 2013 11:30 PM
  • Hi,

    The following link is not available

    (http://msdn.microsoft.com/en-us/library/ms185301.aspx).

    and also, The first project to load in my solution is "Console" (the one what i have mentioned earlier).

    I tried with second solution with DTE, but no success.

    Please suggest.

    Thanks,

    Friday, December 13, 2013 7:18 AM
  • Please try this other link: http://msdn.microsoft.com/en-us/library/vstudio/microsoft.visualstudio.templatewizard.iwizard.runfinished.aspx

    If I think of a better solution I'll post back, otherwise a minimum effort workaround may be to rearrange the order of your projects in your template. However this won't set the default project the way you want if a user is adding your set of projects to a solution with other existing projects.

    Thanks

    Friday, December 13, 2013 11:01 PM
  • Yes, you are right.

    I tried rearranging the order, but it doesn't worked.

    Thanks in advance,

    Monday, December 16, 2013 1:14 PM
  • As far as I know this might be a limitation on Visual Studio. Can you please file a connect bug here [https://connect.microsoft.com/VisualStudio] so that we may consider making this easier in future.

    Thanks!

    Kendagor

    • Marked as answer by Anna Cc Friday, December 27, 2013 12:46 PM
    Tuesday, December 24, 2013 1:25 AM
  • Thanks

    I am not able to log bug at the specified link.

    I am getting page not found error.

    Regards,

    Ravi

    Tuesday, December 24, 2013 6:35 AM
    • Marked as answer by Anna Cc Friday, December 27, 2013 12:45 PM
    Tuesday, December 24, 2013 6:40 AM
  • Any ideas related to this request.

    Because the actual content bug is not yet addressed.

    Thanks in advance

    Wednesday, April 23, 2014 12:51 PM
  • This is several years later, so I don't know if anyone will stumble on to this, but in testing with multi-project templates, regardless of type of project, the ProjectCollection listed first becomes the default startup:

    Solution:

    change this:

    <TemplateContent>
      <ProjectCollection>
       <ProjectTemplateLink  ProjectName ="Console">Client Script\Client.vstemplate </ProjectTemplateLink>
       <ProjectTemplateLink  ProjectName ="Test">Sample Script\Sample.vstemplate</ProjectTemplateLink>   
      </ProjectCollection>
     </TemplateContent>

    to this:

    <TemplateContent>
      <ProjectCollection>
       <ProjectTemplateLink  ProjectName ="Test">Sample Script\Sample.vstemplate</ProjectTemplateLink>   
       <ProjectTemplateLink  ProjectName ="Console">Client 
       Script\Client.vstemplate </ProjectTemplateLink>
      </ProjectCollection>
     </TemplateContent>

    in the .Vstemplate file and the "Test" project will run first

    Wednesday, November 6, 2019 6:14 PM