I am trying to use FAKE to restore my NuGet packages as part of my build script but I need to use a private feed (Artifactory) that requires authentication.
I came across this while searching for a solution. https://github.com/fsharp/FAKE/issues/119
It indicates the issue was resolved via a commit, but I wasn't able to determine where the commit or what version the commit went into and there doesn't seem to be any documented way of usage.
Target "RestorePackages" (fun _ ->
"./**/*.sln"
|> RestoreMSSolutionPackages (fun p ->
{ p with
Sources = "{url}" :: p.Sources
OutputPath = outputDir
Retries = 4 })
)
I looked through the source and found the above snippet though it appears there is no parameters related to authentication unless they're passed into the Sources parameter?
Has anyone had any experience or knowledge on getting FAKE package restore to work with authentication?
You can add credentials to your nuget.config and specify it in your Restore.
{ p with
Sources = p.Sources
OutputPath = outputDir
Retries = 4
ConfigFile = Some "./tools/nuget/nuget.config" }
And then add something like this to your config.
<packageSource>
<add key="feedName" value="http://example.com/Feed.svc" />
</packageSource>
<packageSourceCredentials>
<feedName>
<add key="Username" value="xxx" />
<add key="ClearTextPassword" value="secret" />
</feedName>
</packageSourceCredentials>
https://docs.nuget.org/consume/nuget-config-settings
In the mean time the "ConfigFile" field is not (no longer) available. However you should be able to leverage the hierarchical nature of the nuget.config files (explained here : https://docs.nuget.org/consume/nuget-config-file).
Please also refer the chapter "Credentials for package source" for storing the password in an encrypted fashion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With