首页 > 解决方案 > 删除 NuGet 源(如果存在)

问题描述

我正在尝试检测是否已将源添加到配置文件中。如果已添加,我想将其删除。棘手的部分是我最初不会知道源的名称,但我知道路径。

使用nuget sources list -configfile C:\Temp\NuGet.Config我能够识别已添加的源,但这会返回一个字符串。

如何根据源路径识别是否添加了源并提取源名称以便我可以将其删除?

一些伪代码:

nuget sources add -name "example.com" -source "https://nuget.example.com/nuget" -username "example" -password "example" -storepasswordincleartext -configfile C:\Temp\NuGet.Config

if source exists with path 'https://nuget.example.com/nuget':
    remove source

标签: powershellnuget

解决方案


推荐阅读