在 Visual Studio 项目模板中包含自定义 DLL [英] Include Custom DLL's in Visual Studio Project Template
问题描述
我正在尝试在 Visual Studio 2008 中创建一个项目模板,并且已经成功.
I am trying to create a project template in Visual Studio 2008 and have had success in doing so.
是否可以在我的项目模板中包含一些自定义程序集,以便我在实例化新项目后不必添加对这些程序集的引用?如果可能的话,我会怎么做?
Is it possible to include some custom assemblies in my project template so I don't have to add a reference to these assemblies once I instantiate a new project? If this is possible, how would I go about do this?
推荐答案
我需要自己做这件事.今天最好的方法是创建一个包含所有内容"的 nuget 包 - 例如 DLL.然后将 nuget 包向导添加到 vstemplate 的 WizardExtension 部分,并添加您的 nuget 包(作为对在线存储库的引用,或实际嵌入的 .nupkg 文件)...
I needed to do this myself. The best way to do it today, is to create a nuget package which contains all your 'content' - such as DLLs. Then add the nuget package wizard to the WizardExtension section of your vstemplate, and add your nuget package (as either a reference to an online repository, or the actual embedded .nupkg file)...
您的 nuget 包将打包在您的最终 VSIX 文件中 - 因此,只需双击即可将所有内容推出到 Visual Studio 部署中.当开发者基于你的模板创建新项目时会发生什么,项目结构会被创建,然后 Visual Studio 会看到有一个 Nuget 依赖,它会自动将你的 nuget 包安装到新模板中,并添加对项目的适当引用.
Your nuget package will be packaged in your final VSIX file - so rolling everything out into a Visual Studio deployment will be a simple double click. What will happen when a developer creates a new project based on your template, is the project structure will be created, then Visual Studio will see there is a Nuget dependency, and it will automatically install your nuget package into the new template, and add the appropriate references to the project.
这里有几个关于如何实现这一点的完整解释 - Marcin 的示例有一个可下载的 zip 示例(您可以在他的评论中找到链接):
Here are a couple of fully fleshed out explanations of how to achieve this - Marcin's example has a downloadable zip example (you can find the link in his comments):
这篇关于在 Visual Studio 项目模板中包含自定义 DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!