将 FAKE 与 Nuget 私人订阅源一起使用

Using FAKE with Nuget private feed

我的构建脚本中有以下目标,当我将包的 nuget 提要作为目标时它似乎可以工作,但我的组织使用 artifactory 并且有一个需要凭据的私有提要。

Target "RestorePackages" (fun _ -> 
     "./**/*.sln"
     |> RestoreMSSolutionPackages (fun p ->
         { p with
             Sources = "https://prd-artifactory.jfrog.com:8443/artifactory/api/nuget/some-private-feed" :: p.Sources
             OutputPath = "./packages"
             Retries = 4 
             ConfigFile = Some "./.nuget/nuget.config" })
 )

我需要能够将 username/password 传递给此 Target,这样我就可以 运行 在 TeamCity 上传递要使用的凭据。

NuGet 文档指出您可以运行以下内容:

NuGet.exe Sources Add -Name <feedName> -Source <pathToPackageSource> -UserName xxx -Password <secret> 

但我不确定如何在我的 Target 构建脚本中使用它。

您提到的 Nuget source 命令允许设置凭据以访问给定的包源。
凭据按以下方式添加到 nuget.config 文件:

<packageSourceCredentials>
    <feedName>
        <add key="Username" value="user" />
        <add key="Password" value="...encrypted..." />
    </feedName>
</packageSourceCredentials>

只需确保您在所引用的 nuget.config 文件中有凭据,它应该可以工作。