【问题标题】:MVC Scaffolding Error, deps.json does not existsMVC 脚手架错误,deps.json 不存在
【发布时间】:2017-05-02 07:05:26
【问题描述】:

我正在关注Contoso University,遇到了in this SO question 提到的关于脚手架创建错误的 HP 计算机平台问题,说 deps.json 在某个文件夹中不存在。

我正在运行 Windows 7 Professional 并使用 Visual Studio 2017 Community。

我已通过在命令提示符中使用 set Platform= 将环境变量 Platform 从 BPC 更改为无。

当我尝试 Right Click on the Controllers folder > Add > New Scaffolding Item... > MVC Controller with views, Using Entity Framework > Fill out the form by picking a Model class and Data context class > Add > 时仍然收到错误

Error

There was an error running the selected code generator:
'The specified deps.json [C:\...\bin\BPC\Debug\netcoreapp1.1\ContosoUniversity.deps.json] does not exists'

我已尝试清理解决方案、重新启动 Visual Studio 2017 并重新启动计算机,但均无济于事。 不知道我应该做些什么来防止这个错误。有什么建议么?我觉得将文件复制到 BPC 文件夹是一种解决方法,但不是最佳解决方案。

编辑 1

我注意到环境变量 Platform 被重置为 BPC,所以我将其删除并重新启动。没有回来。

现在,当我尝试创建脚手架时,出现此错误:

Error

There was an error running the selected code generator:
'Value cannot be null.
Parameter name: connectionString
  at
Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b_6_0()
  at
Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
  at
Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)'

编辑 2

手动将 Platform 变量设置回 BCP 会恢复原来的错误。

将所有文件从...\ContosoUniversity\bin\Debug\netcoreapp1.1\ 复制并粘贴到...\ContosoUniversity\bin\BCP\Debug\netcoreapp1.1\ 让我克服了那个错误,但是来自Edit 1 的错误又回来了。

似乎我有两个不同的问题。

【问题讨论】:

    标签: visual-studio entity-framework asp.net-core-mvc


    【解决方案1】:

    原来我在 appsettings.json 中打错字了

    我有 "ConnectionString" 而不是 "ConnectionStrings" 有一个 's'

    这导致了我的Value cannot be null. Parameter name: connectionString 错误

    所以,要解决我最初的问题,请按照 Windows 7 的这些步骤操作。(10 应该没有太大不同):

    Windows key &gt; Right click on Computer &gt; Properties &gt; Advanced system settings &gt; Environment Variables... &gt; Under System variables find Platform &gt; Highlight Platform &gt; Delete &gt; OK

    【讨论】:

      【解决方案2】:

      确保 .json 文件存在于指定的路径中。并告诉我你发现了什么。

      【讨论】:

      • 它不存在。这是问题的一部分。 Visual Studio 或项目应该在文件所在的bin\Debug\...\ 中查找,而不是在空的bin\BPC\Debug\...\ 中查找。
      猜你喜欢
      • 2017-08-03
      • 1970-01-01
      • 2011-10-30
      • 2016-10-10
      • 2023-01-04
      • 2014-10-01
      • 2013-01-22
      • 1970-01-01
      • 2014-09-08
      相关资源
      最近更新 更多