- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我的示例解决方案 > Visual Studio 中有 2 个项目库。我直接在另一个中引用其中一个。当我现在发布我的 nuget 包时,在依赖项概述中我得到我直接引用的 nuget 是 >= 1.0.0.0
,当我通过 nuget 执行它时,引用意味着没有直接引用,因为我得到了相同的解决方案>= 依赖项概述下的正确版本号。我不会更改默认的依赖行为 lowest
。我尝试过的是用 dependencies/references/files 元素更新我的 nuspec 文件,它们都不适合我。我希望在直接引用的 nuget 中看到相同版本的给定 nuget 作为依赖项。
最佳答案
从你问题的最后一句话和你对直接引用的强调让我觉得我知道你在找什么:
NuGet 定义了 -IncludeReferencedProjects
指示选项 nuget.exe
它应该如何对待引用的项目,无论是作为依赖项还是作为包的一部分:
.nuspec
与项目同名的文件,然后将该引用的项目添加为显式 NuGet 依赖项。我猜你是在追求前者。
让我们将问题简化为最基本的形式:假设您有一个解决方案,其中 LibraryA
引用文献 LibraryB
直接作为项目引用。当您构建解决方案时,来自 LibraryA
的程序集输出复制到 LibraryB
~/
│ Solution.sln
├───LibraryA
│ │ ClassA.cs
│ │ LibraryA.csproj
│ │ LibraryA.nuspec
│ ├───bin
│ │ ├───Debug
│ │ │ LibraryA.dll
│ │ │ LibraryA.pdb
│ │ └───Release
│ └───Properties
│ AssemblyInfo.cs
└───LibraryB
│ ClassB.cs
│ LibraryB.csproj
│ LibraryB.nuspec
├───bin
│ ├───Debug
│ │ LibraryA.dll
│ │ LibraryA.pdb
│ │ LibraryB.dll
│ │ LibraryB.pdb
│ └───Release
└───Properties
AssemblyInfo.cs
For illustration purposes I will use the pattern
[assembly: AssemblyVersion("1.0.*")]
in myAssemblyInfo.cs
files and will do a couple of separate builds on each project to ensure my assemblies get some different interesting versions.
确保每个项目都包含一个与项目同名的.nuspec 文件。这对于项目LibraryA
尤为重要。 ,因为它是由 LibraryB
引用的项目.作为良好做法,我会为两者都这样做。现在让我们使用一个基本模板:
在.nuspec
下面,替换 token $id$
和 $version$
当你运行 nuget.exe
时,将得到它们的值推断针对 .csproj
已构建的文件。
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<authors>The author... (**mandatory element**)</authors>
<description>Your description... (**mandatory element**)</description>
</metadata>
</package>
nuget pack -IncludeReferencedProjects
现在,我要运行 nuget.exe
在项目 ~
的解决方案目录 ( LibraryB
) 的命令行中:
PS> nuget pack .\LibraryB\LibraryB.csproj -IncludeReferencedProjects -Verbosity detailed
Attempting to build package from 'LibraryB.csproj'.
Packing files from '~\LibraryB\bin\Debug'.
Using 'LibraryB.nuspec' for metadata.
Add file '~\LibraryB\bin\Debug\LibraryB.dll' to package as 'lib\net451\LibraryB.dll'
Id: LibraryB
Version: 1.0.5993.6096
Authors: The author... (**mandatory element**)
Description: Your description... (**mandatory element**)
Dependencies: LibraryA (= 1.0.5993.7310)
Added file 'lib\net451\LibraryB.dll'.
Successfully created package '~\LibraryB.1.0.5993.6096.nupkg'.
PS>
上述命令将创建一个 NuGet 包 LibraryB.1.0.5993.6096.nupkg
具有对 LibraryA.1.0.5993.7310.nupkg
的显式 NuGet 依赖性.
当您检查 LibraryB.1.0.5993.6096.nupkg
的内容时, 你会看到 .nuspec
由 nuget.exe
生成将替换所有 $version$
将 token 替换为实际使用的版本。
最后一件事,上面的命令将为 LibraryB
创建 NuGet 包但显然你可以为 LibraryA
创建一个只需再次针对 LibraryA.csproj
运行它
我希望这就是您所追求的,或者至少对您可以做什么有所帮助。
关于c# - NuGet 直接项目引用作为版本依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37445144/
我已经在Visual Studio中创建了新的解决方案,启用了nuget包还原,并进入了解决方案根.nuget文件夹,该文件夹包含使包还原正常工作所需的以下文件:NuGet.exe,NuGet.con
自 Nuget 1.5 以来,我的团队一直在使用“启用包还原”选项,以使包不受我们的源代码控制。当 Nuget 1.6 发布时,我们注意到一个问题,即它没有拉取软件包,并跟踪它到 .nuget 文件夹
我维护了一些小的 Nuget 包。 我在 git 存储库中有一个 Nuget README 文件,.nupkg 文件由 VS 根据“Package”配置自动构建,存储在 .csproj 文件。 每当我
我们是一个小型开发团队,我们希望开始使用我们的库作为 NuGet 包。现在我已经看到我们可以创建 NuGet 提要或 NuGet 服务器或 NuGet 画廊。 现在我们不确定有什么区别,对于我们的小团
我正在编写一个脚本,它将自动打包 Nuget 文件并将其发布到我的私有(private)存储库(文件共享)和私有(private)符号服务器(在 localhost 上)。 当我运行 nuget pa
我有一个解决方案,我想从两个项目中创建一个 NuGet 包。 如果它只是一个项目,我会使用 .csproj 文件来规范 NuGet 打包器,但由于我希望两个不同的项目进入完成的包,我不能这样做。 我创
我正在做一个需要处理 Excel 文件的项目。我为这项工作找到了一个名为 Aspose.cells 的库。它不是一个免费的图书馆,我们应该从它的网站购买它的许可证,以便在我们的项目中使用它。但是,我发
我已经使用 Nuget 安装程序创建了一个 TeamCity 构建步骤,但是当我运行这些步骤时出现错误: Updating sources: server side checkout [15:35:4
是否有任何指南或建议来管理不在 nuget 上的库以及在 nuget 上的包。 其中大多数可能是 3rd 方库,除非我们专门安装它们,否则它们可能永远不会继续使用 nuget。 最好将这些 dll 放
我一直在研究自托管 NuGet,但很难理解如何设置它以及它如何帮助支持我们的开发过程。 有没有人对使用哪个,如何设置有任何建议? 或者我应该只使用托管服务? 最佳答案 在查看了各种解决方案(自托管和托
我正在为 OSGeo.FDO 创建 nuget 包,但我遇到了以下问题。 FDO 使用 providers.xml列出它可以使用的所有提供程序的文件。所以我创建了一个名为 OSGeo.FDO 的主包包
我想知道 NuGet 的含义是什么。它是像blah blah get这样的东西吗?它甚至有一个有意义的名字吗?或者它是某物的缩写还是有人为了好玩而决定这个名字?请帮忙,这个问题已经困扰了我 1 周。
This question already has answers here: Is it possible to change the location of packages for NuGet?
如何在 Visual Studio 之外下载 NuGet 包?所以它可以用来创建离线包。 最佳答案 如何在没有 Visual Studio 或 Nuget 包管理器的情况下下载 NuGet 包: 在
我似乎在网络上找不到任何对此表示赞同或反对的地方。谁能指出我的答案吗?或者更好的是,如果您从事 NuGet 工作,您能否给出一些指示,说明是否有任何计划允许商业库包(我认为需要某种身份验证)包含在未来
我已经打开了 TeamCity 的 NuGet 服务器,我想推送公共(public)包(即来自 NuGet.org 等公共(public)资源),因为构建服务器无法看到我们公司外部的信息,因此从 Nu
在我的工作团队中,我们依赖两个 NuGet 提要:来自 NuGet.org 的官方提要用于公共(public)包,而我们文件服务器上的文件夹用于内部包。 这对我们来说效果很好,但我认为我们有一个潜在的
我在我工作的 Web 服务器(在 IIS 7.0 下)上设置了新的 NuGet Gallery。该网站本身已设置并运行良好。我们能够注册帐户、确认电子邮件地址,甚至通过网站本身上传新包。 我们的自动构
当我们在 Visual Studio 2017 中创建 nuget 包时,它默认将项目引用添加为另一个 nuget 引用。 我们如何在创建包时禁用它,而是: 选择不同的包名 在创建包时包含项目的 dl
我可以执行类似 - mono --runtime=v4.0.30319 /Library/TeamCity/buildAgent/work/b0d2d3fefe88d393/.nuget/NuGet.
我是一名优秀的程序员,十分优秀!