Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Edit: answer revised due to misunderstanding of both original request and behavior of previously proposed solution.</p> <p>To set the Start Action of a custom MVC project template, you'll need to create a dll with a class that implements the <code>Microsoft.VisualStudio.TemplateWizard.IWizard</code> interface. To use the wizard dll, you'll either need to copy it to Visual Studio's probing path, which is (VS2010 Install Dir)\Common7\IDE, (VS2010 Install Dir)\Common7\IDE\PrivateAssemblies, or (VS2010 Install Dir)\Common7\IDE\PublicAssemblies. If you don't put the compiled dll in one of those directories, you'll need to strong name and sign the dll and add it to the GAC and get the publickeytoken of the dll and add it to the Assembly element in the vstemplate file.</p> <p>In testing the following code I copied the dll to (VS2010 Install Dir)\Common7\IDE\PrivateAssemblies, so the dll is not signed.</p> <p>Wizard code</p> <pre><code>using System.Collections.Generic; using System.Linq; using System.Xml; using EnvDTE; using Microsoft.VisualStudio.TemplateWizard; namespace WarrenG.StartAction { public class Wizard : IWizard { private readonly Dictionary&lt;string, object&gt; data = new Dictionary&lt;string, object&gt;(); public void RunStarted(object automationObject, Dictionary&lt;string, string&gt; replacementsDictionary, WizardRunKind runKind, object[] customParams) { if (replacementsDictionary.ContainsKey("$wizarddata$")) { string xml = replacementsDictionary["$wizarddata$"]; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); foreach (XmlNode node in doc.ChildNodes) { data.Add(node.Name, node.InnerText); } } } public bool ShouldAddProjectItem(string filePath) { return true; } public void RunFinished() { } public void BeforeOpeningFile(ProjectItem projectItem) { } public void ProjectItemFinishedGenerating(ProjectItem projectItem) { } public void ProjectFinishedGenerating(Project project) { if (data.ContainsKey("WebApplication.DebugStartAction")) { project.Properties.Item("WebApplication.DebugStartAction").Value = data["WebApplication.DebugStartAction"]; } else { project.Properties.Item("WebApplication.DebugStartAction").Value = 1; } } } } </code></pre> <p>Add wizard specific elements to vstemplate file of custom MVC project template</p> <pre><code>&lt;VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project"&gt; &lt;TemplateContent&gt; &lt;!-- various template content --&gt; &lt;/TemplateContent&gt; &lt;!-- add the following --&gt; &lt;WizardExtension&gt; &lt;Assembly&gt;WarrenG.StartAction, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=null&lt;/Assembly&gt; &lt;FullClassName&gt;WarrenG.StartAction.Wizard&lt;/FullClassName&gt; &lt;/WizardExtension&gt; &lt;WizardData&gt; &lt;WebApplication.DebugStartAction&gt;1&lt;/WebApplication.DebugStartAction&gt; &lt;/WizardData&gt; &lt;/VSTemplate&gt; </code></pre> <p>The start actions on the project page appear to be numbers 0 through 4, following their display order. A value of 1 corresponds with Specific Page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload