包.config: Null或空包id

本文关键字:id Null config | 更新日期: 2023-09-27 18:13:04

我试图进入我的包管理器控制台,它给了我以下错误:

An error occurred while reading file 'C:'Users'rein.shope'Documents'Visual Studio 2015'Projects'Vidly'Vidly'packages.config': Null or empty package id

错误显示在窗口顶部的缎带中(带有"Restore"按钮,单击时不执行任何操作)和窗口内的红色文本中。控制台不允许我输入命令。

packages.config含量:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package Id="Antlr" version="3.4.1.9004" targetFramework="net452" />
  <package Id="bootstrap" version="3.0.0" targetFramework="net452" />
  <package Id="EntityFramework" version="6.1.3" targetFramework="net452" />
  <package Id="jQuery" version="1.10.2" targetFramework="net452" />
  <package Id="jQuery.ValIdation" version="1.11.1" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights" version="2.0.0" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights.Agent.Intercept" version="1.2.1" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights.DependencyCollector" version="2.0.0" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights.JavaScript" version="0.22.9-build00167" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.0.0" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights.Web" version="2.0.0" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights.WindowsServer" version="2.0.0" targetFramework="net452" />
  <package Id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.0.0" targetFramework="net452" />
  <package Id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net452" />
  <package Id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net452" />
  <package Id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net452" />
  <package Id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
  <package Id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
  <package Id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net452" />
  <package Id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
  <package Id="Microsoft.CodeDom.ProvIders.DotNetCompilerPlatform" version="1.0.0" targetFramework="net452" />
  <package Id="Microsoft.jQuery.Unobtrusive.ValIdation" version="3.2.3" targetFramework="net452" />
  <package Id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net452" developmentDependency="true" />
  <package Id="Microsoft.Owin" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Security.Facebook" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Security.MicrosoftAccount" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Owin.Security.Twitter" version="3.0.1" targetFramework="net452" />
  <package Id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
  <package Id="Modernizr" version="2.6.2" targetFramework="net452" />
  <package Id="Newtonsoft.Json" version="6.0.4" targetFramework="net452" />
  <package Id="Owin" version="1.0" targetFramework="net452" />
  <package Id="Respond" version="1.2.0" targetFramework="net452" />
  <package Id="WebGrease" version="1.5.2" targetFramework="net452" />
</packages>

所有的Id字段似乎都完好无损。Google搜索"null或空包id"没有返回任何结果。

包.config: Null或空包id

尝试将所有Id更改为id(小写)。

我有同样的问题,奇怪的是这是发生在包。配置

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package MovieID="Antlr" version="3.5.0.2" targetFramework="net472" />
  <package MovieID="bootstrap" version="3.4.1" targetFramework="net472" />
  <package MovieID="jQuery" version="3.3.1" targetFramework="net472" />
  <package MovieID="jQuery.ValiMovieIDation" version="1.17.0" targetFramework="net472" />
  <package MovieID="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net472" />
  <package MovieID="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net472" />
  <package MovieID="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net472" />
  <package MovieID="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net472" />
  <package MovieID="Microsoft.CodeDom.ProvMovieIDers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net472" />
  <package MovieID="Microsoft.jQuery.Unobtrusive.ValaMovieIDation" version="3.2.11" targetFramework="net472" />
  <package MovieID="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
  <package MovieID="Modernizr" version="2.8.3" targetFramework="net472" />
  <package MovieID="Newtonsoft.Json" version="11.0.1" targetFramework="net472" />
  <package MovieID="WebGrease" version="1.6.0" targetFramework="net472" />
</packages>

注意所有的d字母都变成了MovieID我认为这是一个错误,我使用的是VS社区2019年的最新版本你可以手动修复

我猜这是由于resharper或一些类似的工具造成的。最初,我重命名了变量name, resharper将其应用于项目中的所有文件,甚至包。config。所以最好照顾好这个功能:)

重命名回id解决了这个问题