简体   繁体   English

无法解析配置文件'nuget.config'

[英]Unable to parse config file 'nuget.config'

I'm getting the following error when attempting to "Manage NuGet packages" for a multi-project solution in Visual Studio 2015. The same error also occurs when trying to manage the packages at a project level for all but two projects within the solution: 尝试为Visual Studio 2015中的多项目解决方案“管理NuGet程序包”时出现以下错误。尝试为解决方案中除两个项目以外的所有项目在项目级别管理程序包时,也会发生相同的错误:

VS错误的屏幕截图

The content of the above mentioned file is as follows: 上述文件的内容如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <config>
    <add key="repositoryPath" value="..\..\..\packages" />
  </config>
  <activePackageSource>
    <add key="nuget.org (http)" />
    <add key="xxxxx NuGet Server" />
  </activePackageSource>
  <packageSources>
    <add key="nuget.org (http)" value="http://www.nuget.org/api/v2/" />
    <add key="xxxxx NuGet" value="\\10.180.1.119\xxxxx\NuGet" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
    <add key="xxxxx  NuGet Server" value="http://10.141.129.81:9091/nuget" />
    <add key="Octopus Internal Feed" value="http://10.180.1.119:8081/nuget/packages" />
  </packageSources>
  <disabledPackageSources>
    <add key="nuget.org" value="true" />
    <add key="Octopus Internal Feed" value="true" />
  </disabledPackageSources>
</configuration>

After clicking OK on this error, nothing happens - it doesn't continue and thus doesn't allow me to make package changes. 在针对该错误单击“确定”后,什么都没有发生-它不会继续,因此不允许我进行程序包更改。

However, if I open the solution in Visual Studio 2013, I don't get the error at all, and I can get into the package manager as expected: 但是,如果我在Visual Studio 2013中打开解决方案,则根本不会收到错误,并且可以按预期进入软件包管理器:

Visual Studio 2013套件管理员

Any help would be appreciated, as keeping and running VS2013 just to manage packages feels like using a sledgehammer to crack a nut :/ 任何帮助将不胜感激,因为保持和运行VS2013只是为了管理软件包就像使用大锤破解螺母一样:/

A parsing error means the format/syntax of the file is wrong. 解析错误表示文件的格式/语法错误。

To be more precise, it means that the current format/syntax of the file is not the expected format/syntax from the reader point of view. 更准确地说,这意味着从读者的角度来看,文件的当前格式/语法不是预期的格式/语法。

Why a parsing error could happen ? 为什么会发生解析错误?

  • manual (error prone) change to the file. 手动(容易出错)更改文件。
  • new version of the software which reads the file. 读取文件的软件的新版本。 (seems to be the root cause here) (这似乎是根本原因)

Pinpoint the problem 查明问题

Fast way for small files 小文件的快速方法

Comment incrementally parts of the file and check if the parsing error still occurs. 逐步注释文件的一部分,并检查是否仍然发生分析错误。 By doing so wisely, you should be able to pinpoint what's wrong. 通过明智地这样做,您应该能够找出问题所在。

Long way but better 很长的路要走,但是更好

Read the documentation, learn the expected syntax and format, and then any parsing error would become obvious. 阅读文档,学习所需的语法和格式,然后任何解析错误都会变得很明显。

The problem is that current nuget documentation probably doesn't apply to visual studio 2015 (which is not supported anymore, ended on October 10th, 2017). 问题在于当前的Nuget文档可能不适用于Visual Studio 2015(不再受支持,于2017年10月10日结束)。

Use a supported version of Visual Studio (2017 or 2019) would be the recommended way to go. 建议使用支持的Visual Studio版本(2017或2019)。

Recreate the file with NuGet 用NuGet重新创建文件

NuGet can modify the configuration file in command line and even create a brand new file. NuGet可以在命令行中修改配置文件,甚至可以创建一个全新的文件。

For example: 例如:

nuget config -set repositoryPath=..\..\..\packages -config NuGet.config

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM