1
votes

I have the following Target in my build script and it seems to work when I target the nuget feed for packages but my organization uses artifactory and has a private feed that requires credentials.

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" })
 )

I need to be able to pass in the username/password to this Target so I can run this on TeamCity passing in the credentials to use.

NuGet documentation states that you can run the following:

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

But I am not sure how to use this in my build script for the Target.

1
I think there are pre-authenticated urls for TC. (Which contain the login data in the url)forki23
Has something changed because I can't find the property for "ConfigFile" fsharp.github.io/FAKE/apidocs/…paulio

1 Answers

1
votes

The Nuget source command you mentioned allows setting the credentials to access the given package source.
The credentials are added to the nuget.config file in the following manner:

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

Just make sure you have the credentials in the nuget.config file you are referring to and it should work.