我正在尝试创建一个多项目模板。我希望子项目名称包含解决方案名称。我已经尝试了以下方法,但是由于某些原因,$safeprojectName$在根模板中不起作用。它尝试在名称中使用$safeprojectName$而不是实际的项目名称来创建文件夹。
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Default Solution</Name>
<Description>An example of a multi-project template</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<SolutionFolder Name="$safeprojectName$.Web">
<ProjectTemplateLink ProjectName="$safeprojectName$.Web">
Src\Web\MyTemplate.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
</ProjectCollection>
</TemplateContent>
</VSTemplate>我对此做了大量的阅读,并且已经使用创建参数$solutionName$的IWizard接口创建了一个程序集。然后,我使用了以下模板。
<VSTemplate Version="2.0.0" Type="ProjectGroup"
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Default Solution</Name>
<Description>An example of a multi-project template</Description>
<Icon>Icon.ico</Icon>
<ProjectType>CSharp</ProjectType>
</TemplateData>
<TemplateContent>
<ProjectCollection>
<SolutionFolder Name="$solutionName$.Web">
<ProjectTemplateLink ProjectName="$solutionName$.Web">
Src\Web\MyTemplate.vstemplate
</ProjectTemplateLink>
</SolutionFolder>
</ProjectCollection>
</TemplateContent>
<WizardExtension>
<Assembly>DefaultSoloutionWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=f753ddb61a28cb36, processorArchitecture=MSIL</Assembly>
<FullClassName>DefaultSoloutionWizard.WizardImplementation</FullClassName>
</WizardExtension>
</VSTemplate>然而,由于同样的问题,这也失败了。我在试着做不可能的事吗?在这方面的任何帮助都将是非常受欢迎的。
发布于 2009-06-29 16:32:38
您可能需要查看Guidance Automation Toolkit。有相当多的东西需要消化,但它可以做的一部分是在多项目模板上放置一个基于向导的UI。
如果您想了解其中的一个示例,可以查看Service Factory,它可以部分地基于向导创建整个解决方案结构。
发布于 2014-09-16 05:20:33
从Visual Studio2013Update2开始,您现在可以在根.vstemplate文件中的ProjectTemplateLink元素上使用CopyParameters属性。在根模板中定义的任何参数都将在带有"ext_“前缀的链接模板中可用。
例如,如果根模板定义了参数$Foo$,则参数$ext_Foo$将在具有相同值的链接项目中可用。
有关更多详细信息,请参阅http://msdn.microsoft.com/en-us/library/ms171398.aspx。
发布于 2011-01-19 03:54:49
可以,您需要在根模板的向导中使用静态字典,它将被下级模板的向导实现使用:
根模板中的IWizard实现
public void RunStarted(object automationObject,
Dictionary<string, string> replacementsDictionary,
WizardRunKind runKind, object[] customParams)
{
try
{
// Display a form to the user. The form collects
// input for the custom message.
inputForm = new UserInputForm();
inputForm.ShowDialog();
customMessage = inputForm.get_CustomMessage();
// Add custom parameters.
replacementsDictionary.Add("$custommessage$",
customMessage);
globalDictionary = new Dictionary<string, string>();
globalDictionary.Add("$custommessage$",
customMessage);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public static Dictionary<string, string> globalDictionary;您可以在此处获得实现的完整示例:Multi-Project Templates with Wizard: Visual Studio 2010 Sample
https://stackoverflow.com/questions/1059152
复制相似问题