来自 VSCODE 的 Nuget 找错了地方

Nuget from VSCODE is looking in the wrong place

我在 VSCode 中创建新的 c# Azure Functions 项目时遇到错误。该项目生成良好,但当我尝试构建并且 运行 时,nuget 包管理器在错误的位置查找,它正在私有 Azure DevOps 包存储库中寻找 Azure 包。

我看到 post 建议我将 nuget.config 添加到项目根目录(在 .csproj 级别),但这没有帮助。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <packageSources>
    <add key="ArtifactoryNuGetV3" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
 </packageSources>
</configuration>

有什么想法吗?下面是错误,很明显是找错地方了。 MYCUSTOMER 包源已在我的 Visual Studio 2019 中注册,但离 VSCode 项目不远,我假设有一些全局设置在某处弄脏了东西,但我找不到它。

Retrying 'FindPackagesByIdAsyncCore' for source 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Host.Storage'&semVerLevel=2.0.0'. The content at 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Host.Storage'&semVerLevel=2.0.0' is not valid XML. For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. Retrying 'FindPackagesByIdAsyncCore' for source 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Extensions'&semVerLevel=2.0.0'. The content at 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Extensions'&semVerLevel=2.0.0' is not valid XML. For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. Retrying 'FindPackagesByIdAsyncCore' for source 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Extensions'&semVerLevel=2.0.0'. The content at 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Extensions'&semVerLevel=2.0.0' is not valid XML. For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. Retrying 'FindPackagesByIdAsyncCore' for source 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Host.Storage'&semVerLevel=2.0.0'. The content at 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Host.Storage'&semVerLevel=2.0.0' is not valid XML. For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. Retrying 'FindPackagesByIdAsyncCore' for source 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'&semVerLevel=2.0.0'. The content at 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'&semVerLevel=2.0.0' is not valid XML. For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. Retrying 'FindPackagesByIdAsyncCore' for source 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'&semVerLevel=2.0.0'. The content at 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.NET.Sdk.Functions'&semVerLevel=2.0.0' is not valid XML. For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. C:\Program Files\dotnet\sdk.1.102\NuGet.targets(123,5): error : Failed to retrieve information about 'Microsoft.Azure.WebJobs.Host.Storage' from remote source 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Host.Storage'&semVerLevel=2.0.0'. [c:\dev\DuroFunc\DuroFunc.csproj] C:\Program Files\dotnet\sdk.1.102\NuGet.targets(123,5): error : The content at 'https://dev.azure.com/MYCUSTOMER-dev/MyCust.Packages/_packaging?_a=connect&feed=MyCust.Packages.Backend/FindPackagesById()?id='Microsoft.Azure.WebJobs.Host.Storage'&semVerLevel=2.0.0' is not valid XML. [c:\dev\DuroFunc\DuroFunc.csproj] C:\Program Files\dotnet\sdk.1.102\NuGet.targets(123,5): error : For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. [c:\dev\DuroFunc\DuroFunc.csproj] Done: 1.

是的,我得到了这样的东西并花了一段时间寻找它。

刚刚升级了我的桌面 VS2017 -> VS2019 和 .Net Core 2.1 -> 3.1,但这可能不相关。

我用

清除了 NuGet 缓存

dotnet nuget locals --clear all

NuGet 在那之后有点困惑,所以我恢复了包,清理并构建了解决方案,它运行良好。

这有帮助:https://github.com/dotnet/AspNetCore.Docs/issues/13366

HTH