-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add dotnet nuget <add|remove|update|disable|enable|list> source
command
#4126
Comments
Are there any plans for this to be looked at sometime soon? There's currently no way to add the source with authentication through the dotnet cli. The only workaround is to add the source then manually patch the config, which is far from ideal. |
Any idea of when this will be added? :( |
yes any update? |
Wondering the status of this as well - hitting this on the non-Windows platforms right now where NuGet.exe doesn't exist. |
For those stuck and needing a workaround for docker, like I did, this is what I did for now:
The idea is that you would set the environment variables, then invoke the docker compose to make the build happen inside the docker container, mapping the source folder into the container. As a quick note, the build will happen as the root user, so your file ownership may be root at the end. I find this type of work around unsuitable and really hope that Microsoft adds a wrap that allows us to just pass in the username/password for each nuget source as part of the command line. |
Hello @TheRealPiotrP , Would you happen to know if this is on the team's radar? I see that there is a spec for a cross-platform credentials plugin but I don't see it being developed for generic uses, only for Azure pipelines: https://github.com/NuGet/Home/wiki/NuGet-Cross-Plat-Credential-Plugin In any case, Is this something that I can attempt to develop and open a PR for or does the NuGet team have other plans (e.g. the credential plugin)? Thanks! |
We'd love to see this feature added so we can streamline the process of setting up and using an Azure Artifacts private NuGet feed. |
Agreed - if it's not on the radar, I could help out on this as well. As my team moves more and more to cross-platform .NET Core it would be great to have it. |
We need to support this, else GitHub Package Registry cannot use it. |
@clarkbw FYI that this will make it easier to configure |
note, since these earlier discussions, the ADO (azure dev ops) team has shipped an artifacts credential provider: https://github.com/Microsoft/artifacts-credprovider That said, we do want to move an implementation of nuget sources to dotnet.exe. here is the help output from "nuget sources -help"
To learn more about NuGet configuration go to https://docs.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior.
|
@anangaur yep, it expires shortly after the run ends. |
ah ok, so this whole thing is really just an ask for encrypted passwords in nuget.config via dotnet.exe? this issue is confusing...cause the title asks for the command. and during the thread, somebody says having a cross platform credential provider would solve it too.
are all these requests just asking us for 3? |
|
I agree. Not necessary or urgent but encryption will be great to have for dev machine scenarios. Not so much for Actions as they run temporarily and the GITHUB_TOKEN anyway expires after use. /cc: @zivkan |
Yeah, and encryption is important to enterprise security types but there seems to be a strong culture on Mac and Linux of putting tokens in the home directory and using file system permissions to keep them limited access. Not my area of expertise, just an observation. |
As a temporary workaround, here's a basic powershell script that can be used with Powershell Core anywhere that the dotnet cli runs: [CmdletBinding()]
param (
[Parameter(Mandatory = $true)][string]$ConfigFile,
[Parameter(Mandatory = $true)][string]$Source,
[Parameter(Mandatory = $true)][string]$Username,
[Parameter(Mandatory = $true)][string]$Password
)
$doc = New-Object System.Xml.XmlDocument
$filename = (Get-Item $ConfigFile).FullName
$doc.Load($filename)
$creds = $doc.DocumentElement.SelectSingleNode("packageSourceCredentials")
if ($creds -eq $null)
{
$creds = $doc.CreateElement("packageSourceCredentials")
$doc.DocumentElement.AppendChild($creds) | Out-Null
}
$sourceElement = $creds.SelectSingleNode($Source)
if ($sourceElement -eq $null)
{
$sourceElement = $doc.CreateElement($Source)
$creds.AppendChild($sourceElement) | Out-Null
}
$usernameElement = $sourceElement.SelectSingleNode("add[@key='Username']")
if ($usernameElement -eq $null)
{
$usernameElement = $doc.CreateElement("add")
$usernameElement.SetAttribute("key", "Username")
$sourceElement.AppendChild($usernameElement) | Out-Null
}
$usernameElement.SetAttribute("value", $Username)
$passwordElement = $sourceElement.SelectSingleNode("add[@key='ClearTextPassword']")
if ($passwordElement -eq $null)
{
$passwordElement = $doc.CreateElement("add")
$passwordElement.SetAttribute("key", "ClearTextPassword")
$sourceElement.AppendChild($passwordElement) | Out-Null
}
$passwordElement.SetAttribute("value", $Password)
$doc.Save($filename) I used it in a GitHub Actions workflow with the following YAML: - name: Set NuGet creds
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./Set-NuGetCredentials -ConfigFile ./nuget.config -Source gpr-test -Username zivkan -Password $env:GITHUB_TOKEN |
dotnet nuget sources
command
dotnet nuget sources
commanddotnet nuget <add|remove|update|disable|enable|list> source
command
Fixes: NuGet/Home#4126 Fixes: NuGet/Home#8668 Spec link: https://github.com/NuGet/Home/blob/dev/designs/DotNet-Sources-Support.md ## Main Work - `dotnet nuget add|remove|* source` implementation Moves and refactors existing `NuGet.exe sources add|remove|*` command into NuGet.Commands.csproj, so that it can be called by NuGet.exe and by DotNet.exe. ## Localization fixes were then necessary Dealt with some localization challenges as part of the strings that moved into NuGet.Commands.dll. Needed to make the ILMerge command that makes NuGet.exe to get localization strings from the 13 NuGet.Commands.resources.dll. ## CodeGeneration templates and datafile for commands/verbs Also implemented a CodeGeneration engine (see .tt files) based on data in commands.xml - which automated code creation of much of the infrastructure. As we add more commands into dotnet.exe, this should be useful.
Great work @rrelyea! 👍 Any ETA for when the fix will be released so we can start using it? Can't wait to throw out my bodges from my pwsh-scripts 😁 |
This is great news |
@OskarKlintrot -This should ship during the NuGet 5.5 wave. We hope to insert a build that contains this into VS 16.5p3 daily builds today. |
When there is a |
Why is this closed. Problem still exists. |
Update on 2/6/2020 from @rrelyea:
Fixed with: NuGet/NuGet.Client#3206
Spec link: https://github.com/NuGet/Home/wiki/Add-nuget-sources-command-to-the-dotnet-CLI
Original text:
Moving from https://github.com/dotnet/cli/issues/5053#issuecomment-267794961 on behalf of @meichtf, @emgarten.
Steps to reproduce
try to add a username/ClearTextPassword in the dotnet restore --source command
Expected behavior
My nuget repository requires authentication and it is not possible to add a username/ClearTextPassword in the dotnet restore command for a source
Actual behavior
It's not possible to add a username/ClearTextPassword for a ..source
Environment data
dotnet --info
output:.NET Command Line Tools (1.0.0-preview2-1-003177)
Product Information:
Version: 1.0.0-preview2-1-003177
Commit SHA-1 hash: a2df9c2576
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
The text was updated successfully, but these errors were encountered: