问题描述
最近,我开始从我的几个项目中打包 nuget 包.首先,我从 Package Explorer 应用程序开始.这是一个不错的工具,但如果您进行持续集成,它的用处就会降低.然后我研究了指定 nuspec 模板文件,并传递不断变化的数据,例如版本号,作为命令行参数.后来想知道如何定义nuget包依赖.事实证明,如果您指定 csproj,nuget.exe 已经基于 package.config 执行此操作.此外,它还从程序集信息中提取作者、版本、版权等相关数据.我现在缺少的是在命令行中指定 licenseUrl 的能力.但我希望这个问题更笼统.所以我问:
Recently, I started to pack nuget packages out of my several projects. First I started with the Package Explorer application. It is a nice tool, but it's less useful if you do continuous integration. Then I looked into specifying the nuspec template file, and passing changing data, e.g. version number, as command line arguments. Later, I wondered how to define the nuget package dependencies. As it turns out, the nuget.exe already does this based on the package.config if you specify a csproj. Moreover, it extracts relevant data like Author, Version, Copyright right from the assembly info. What I'm missing right now is the ability to specify a licenseUrl in the command line. But I wanted the question to be more generic. And so I'm asking:
打包 nuget 包的首选方式是什么?
推荐答案
这是一个鲜为人知的事实:您可以将两者结合起来!以 csproj 文件为目标,并确保在同一目录中有一个与 csproj 文件同名的 nuspec 文件.NuGet 将在包创建过程中将两者合并.
Here's a little-known fact: you can combine both! Target a csproj file, and make sure there's a nuspec file in the same directory with the same name as the csproj file. NuGet will merge the two during package creation.
简而言之:目标<ProjectName>.csproj
,可选择添加相应的tokenized <ProjectName>.nuspec
文件被 NuGet.exe 用作元数据.
So in short: target <ProjectName>.csproj
, optionally add a corresponding tokenized <ProjectName>.nuspec
file to be used as metadata by NuGet.exe.
它使您免于管理输出位置、依赖项、版本和其他可以从项目派生的东西.
It saves you from managing output location, dependencies, version, and other stuff that can be derived from the project.
这篇关于nuget 打包 csproj 与 nuspec 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!