I am trying to use the library NuGet.Configuration from NuGet to programmatically add a packageSource to my nuget.config. (I can't use nuget.exe in AWS CodeBuild, at least without a ton of heavy lifting).
I can't make heads or tails of the NuGet.Configuration classes and how to operate them.
Essentially what I want to do is:
I can't find any examples out there. Advise?
No time to "dress this up" but essentially it is this:
var setting = Settings.LoadSpecificSettings(Directory.GetCurrentDirectory(), "NuGet.Config");
// get sources
var packageSourceProvider = new PackageSourceProvider(setting);
var packageSource = new PackageSource(repo.RepositoryEndpoint, "my-repo")
{
Credentials = new PackageSourceCredential("my-repo", "aws", authorizationTokenAsync.AuthorizationToken, true, string.Empty)
};
packageSourceProvider.AddPackageSource(packageSource);
setting.SaveToDisk();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.