首页 文章

Nuget打包csproj与其他csproj的依赖关系

提问于
浏览
1

我有两个项目

  • A.csproj

  • B.csproj

其中B引用A(对解决方案中的项目的引用)

I want to automate creation of packages, where package B will contain dependecy to package A

我使用 nuget spec A.csproj 生成了nuspec,并使用 nuget pack A.csproj 创建了包 . 项目B也是如此 .

然而B.nuspec不包含对nuget包A的依赖性?

我想在TFS构建服务器上自动创建nuget包,其中在构建时确定程序集版本 .

在包B中,如何使用正确的版本向包A添加依赖性?

1 回答

  • 0

    首先,要将引用的项目添加为包的一部分,您需要使用 IncludeReferencedProjects 选项 . 命令行类似"nuget pack A.csproj -IncludeReferencedProjects"

    其次,由于您希望在TFS构建过程中创建NuGet包,您需要创建一个类似于以下内容的PowerShell脚本,并在预构建脚本中包含PowerShell脚本(假设您使用的是TFS2013或TFS2015) .

    $projectFile = "project.csproj"
    $nugetPath = “NuGet.exe"
    $version = $Env:TF_BUILD_BUILDNUMBER
    Write-Host ("packing $projectFile...")
    & $nugetPath pack "$projectFile" -Version $version -Symbols -IncludeReferencedProjects
    

相关问题