问题描述
是否有说明在项目模板中添加nuget和引用?
最好的方法是添加不带版本的nuget.不是从nuget.org中添加Nuget,而是从内部公司资源中添加.
The best way is to add nuget without version.Nugets will be added not from nuget.org but from internal corporate resource.
我的意思是.在 SolutionExplorer图片中,红色框是nuget的引用,蓝色框是使用nuget引用的Add reference
.
What I mean. In the SolutionExplorer picture red boxes are references from nugets and blue boxes are references were included using Add reference
.
使用Export template
后,我在zip文件夹中看不到任何引用 .
After I used Export template
I don't see any references in zip folder.
当我使用模板创建新项目时,我在nuget引用上看到错误,而在PC上的引用上没有错误(但是它们的绝对路径不在项目中,因此我无法将模板分发给其他开发人员).
And when I create new project with my template I see errors on nuget references and no errors on references from PC(but their absolute pathes are not in the project so I can't distribute template to other developers).
推荐答案
有关使用nuget packagaes创建项目模板的特定说明,请参见 nuget.org .不幸的是,无法在没有版本号的情况下将nuget包添加到项目模板中:
Specific instructions for creating a project template with nuget packagaes are documented at nuget.org. Unfortunately, it is not possible to add a nuget package to a project template without a version number:
此行为的原因是软件包的将来版本 可能会引入与项目/项目不兼容的更改 模板.选择将软件包升级到最新版本 使用NuGet留给最合适的开发人员 承担将软件包升级到最新版本的风险.
The reason for this behavior is that a future version of a package might introduce a change that is not compatible with the project/item template. The choice to upgrade the package to the latest version using NuGet is left to the developer who is in the best position to assume the risks of upgrading the package to the latest version.
vstemplate(需要在模板膨胀时调用软件包下载):
vstemplate (this is required to invoke package download at template inflation):
<WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
包装清单:
<WizardData>
<packages>
<package id="jQuery" version="1.6.2" />
</packages>
</WizardData>
上面链接的nuget网站上记录了其他选项,例如,创建VSIX
模板.
There are additional options documented on the nuget site linked above, such as creating a VSIX
template.
这篇关于如何在Visual Studio项目模板中添加引用和nuget?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!