简体   繁体   English

带有自定义 .nuspec 元数据的 nuget 包 .csproj

[英]nuget pack .csproj with custom .nuspec metadata

I would like to pack nuget package using a .csproj file.我想使用.csproj文件打包 nuget 包。 Following command will be executed:将执行以下命令:

nuget pack MyProject.csproj -IncludeReferencedProjects

In the project folder I have two nuspec files, one depending to the MyProject.csproj and another which will be used to make a different package but depending on this project to.在项目文件夹中,我有两个 nuspec 文件,一个取决于 MyProject.csproj,另一个将用于制作不同的包,但取决于此项目。 Folder structure looks like:文件夹结构如下:

-ProjectFolder
 |-MyProject.csproj
 |-AdditionalMyProject.nuspec
 |-MyProject.nuspec

When calling the nuget pack command, it always takes the first nuspec file ( AdditionalMyProject.nuspec - lower naming) to get metadata for nuget package but the correct nuspec should be MyProject.nuspec (matching the name of project file).调用nuget pack命令时,它总是使用第一个 nuspec 文件( AdditionalMyProject.nuspec - 较低的命名)来获取 nuget 包的元数据,但正确的 nuspec 应该是MyProject.nuspec (与项目文件的名称匹配)。

Is there a way to tell nuget pack which nuspec it should use when packing a csproj?有没有办法告诉 nuget pack 在打包 csproj 时应该使用哪个 nuspec?

Something like this:像这样的东西:

nuget pack MyProject.csproj -nuspec MyProject.nuspec -IncludeReferencedProjectsenter

AdditionalMyProject.nuspec is a different project, even if it doesn't have a MSBuild project associated (it is a different .nupkg after all), so you're less likely to have tooling problems if you keep the nuspec in its own directory. AdditionalMyProject.nuspec 是一个不同的项目,即使它没有关联的 MSBuild 项目(毕竟它是一个不同的 .nupkg),因此如果将 nuspec 保留在其自己的目录中,则不太可能出现工具问题。 Similar to how different csproj files live in different directories, even when one has a dependency on the other, I recommend putting the different .nuspec files in different directories, even if MyProject is a nuget dependency of AdditionalMyProject.类似于不同的 csproj 文件如何存在于不同的目录中,即使一个依赖于另一个,我建议将不同的 .nuspec 文件放在不同的目录中,即使 MyProject 是 AdditionalMyProject 的 nuget 依赖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NuGet Pack-针对nuspec或csproj打包的不同问题 - NuGet Pack - Different Problems Packing Against nuspec or csproj 如何在生成的 .nuspec 的 MSBuild NuGet 包中注入自定义依赖项 - How to inject a custom dependency in an MSBuild NuGet pack generated .nuspec nuget-packing csproj与nuspec之间的差异 - Differences between nuget-packing a csproj vs. nuspec 无法使用 dotnet CLI 和 nuspec 文件打包 NuGet 包 - Unable to pack a NuGet package using dotnet CLI and nuspec file 使用 csProj 发布到 NuGet:如何添加元数据? - Publishing to NuGet using csProj: How to add Metadata? 使用 Nuget 包创建 Nuget Package 说要将 net6.0 的依赖组添加到 nuspec 和需要的点? - Creating a Nuget Package with Nuget Pack Says to Add a dependency group for net6.0 to the nuspec and Dots Required? 从nuspec文件的不同文件夹中包含的多个csproj创建多目标nuget包 - Create multi-target nuget package from several csproj contained in different folders from nuspec file Nuget pack 3.4.3 csproj + project.json包含依赖项 - Nuget pack 3.4.3 csproj + project.json include dependencies Azure DevOps NuGet Pack 忽略 csproj 包详细信息 - Azure DevOps NuGet Pack is ignoring csproj package details 如何从csproj生成nuspec中的依赖项(或nupkg的元数据中包含依赖项) - How to generate dependencies in nuspec (or nupkg contains dependencies in its metadata) from csproj
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM