在我开始讲问题之前,让我快速解释一下我的目标:
我有一个模板项目,用于构建每个网站,其中包括基础类、常见页面(例如联系我们)、有用的工具(异常日志记录)等。我想使这个模板可重复使用和更新。之前我使用的是Visual Studio项目模板,但我在引用所需的所有程序集方面遇到了问题,因此我转向了Nuget。我认为这样会更容易,并提供额外的好处。
问题是:
我无法弄清楚如何创建一个Nuget包,该包将包含所有引用(包括解决方案中的其他项目和本地机器上的dll),并使它们成为安装此模板的子项目的依赖项。
这是我所做的:
a. 在项目的nuspec文件中,我有以下内容:
symbols pkg:
此时,感觉一切都做得没问题。 但是,一旦我在Visual Studio中创建一个新的空Web应用程序并安装此软件包,这些引用的程序集或项目都不包括在引用中:
d. 在Visual Studio中的新(子)项目中:
我已经遇到了完全的瓶颈。 我已经在网上搜索了几天,发现了一堆看起来可能有用的东西,但都走了死胡同:
![enter image description here](https://istack.dev59.com/joqXe.webp)
(来源:blabberjax.com)
我有一个模板项目,用于构建每个网站,其中包括基础类、常见页面(例如联系我们)、有用的工具(异常日志记录)等。我想使这个模板可重复使用和更新。之前我使用的是Visual Studio项目模板,但我在引用所需的所有程序集方面遇到了问题,因此我转向了Nuget。我认为这样会更容易,并提供额外的好处。
问题是:
我无法弄清楚如何创建一个Nuget包,该包将包含所有引用(包括解决方案中的其他项目和本地机器上的dll),并使它们成为安装此模板的子项目的依赖项。
这是我所做的:
a. 在项目的nuspec文件中,我有以下内容:
<references>
<reference file="AjaxControlToolkit.dll" /> <!-- nuget dependency -->
<reference file="BjxContacts.Shared.dll" /> <!-- project dependency -->
<reference file="SomeExample.exe" /> <!-- exe local file dependency -->
<reference file="SomeOther.dll" /> <!-- dll local file dependency -->
</references>
<files>
<file src="bin\*.pdb" target="lib" />
<file src="bin\*.dll" target="lib"/>
<file src="bin\*.exe" target="lib"/>
<file src="bin\*.xml" target="lib"/>
</files>
b. 运行pack命令时,我使用以下命令:nuget pack {projectname}.csproj - IncludeReferencedProjects -Symbols
c. 输出结果是两个独立的项目,一个带有.symbols,一个没有,如Package Explorer中所示:
两个项目:
![enter image description here](https://istack.dev59.com/sQEHf.webp)
![enter image description here](https://istack.dev59.com/uuojn.webp)
![enter image description here](https://istack.dev59.com/vyBsx.webp)
- https://github.com/dittodhole/powershell-nuget-packager
- Build NuGet Package automatically including referenced dependencies
- NuGet Packaging and referencing dll's
- Why doesn't nuget include the referenced project when packing?
![enter image description here](https://istack.dev59.com/joqXe.webp)
(来源:blabberjax.com)