[英]Programmatically Add a packageSource to packageSources in Nuget.Config
我正在嘗試使用庫 NuGet.Configuration 來自 NuGet 以編程方式將 packageSource 添加到我的 nuget.config。 (我不能在 AWS CodeBuild 中使用 nuget.exe,至少沒有大量的繁重工作)。
我無法弄清楚 NuGet.Configuration 類以及如何操作它們。
基本上我想做的是:
我在那里找不到任何例子。 建議?
沒時間“裝扮一下”,但本質上是這樣的:
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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.