预期的锁文件不存在.请执行命令"dnu restore""在我做完之后

本文关键字:quot restore dnu 之后 不存在 文件 执行 命令 | 更新日期: 2023-09-27 18:14:44

我正在运行所有的beta7,包括EF 7。我试图连接到我的远程现有数据库使用ASP。. NET 5应用程序模板项目。我的项目。Json是这样的:

{
  "webroot": "wwwroot",
  "userSecretsId": "aspnet5-XXX-409e9e37-b7bb-4185-b7aa-6dc336087524",
  "version": "1.0.0-*",
  "dependencies": {
    "EntityFramework.Commands": "7.0.0-beta7",
    "EntityFramework.SqlServer": "7.0.0-beta7",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
    "Microsoft.AspNet.Mvc": "6.0.0-beta7",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
    "Microsoft.Framework.Logging": "1.0.0-beta7",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
    "Microsoft.Framework.Logging.Debug" : "1.0.0-beta7",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7"
  },
  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
    "ef": "EntityFramework.Commands"
  },
  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },
  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
   "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
  }
}

在网上搜索,似乎为了完成我想要的,我需要运行以下命令:

dnx ef dbcontext scaffold "ConnectionString" EntityFramework.SqlServer

我不能这样做,因为我有一个问题,解决如下所述:使用现有的数据库与ASP。. NET 5和EF7 (beta 7)

现在我终于可以运行命令"dnx",但是当我尝试用我的connectionstring运行它时,它看起来像这样:

dnx ef dbcontext scaffold "Data Source=192.168.XX.XXX'devsql;Initial
Catalog=Development;Integrated Security=False;User ID=system;Password=XXX;"
EntityFramework.SqlServer

它给了我以下错误:

[ERROR] dnx : System.InvalidOperationException: Failed to resolve the
following dependencies for target framework 'DNXCore,Version=v5.0':
[ERROR] En línea: 1 Carácter: 1 [ERROR] + dnx ef dbcontext scaffold
"Data Source=192.168.XX.XXX'devsql;Initial Catalog=Dev ... [ERROR] +
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR]     + CategoryInfo          : NotSpecified:
(System.InvalidO...,Version=v5.0'::String) [], RemoteException [ERROR]
+ FullyQualifiedErrorId : NativeCommandError [ERROR]   [ERROR]    EntityFramework.Commands 7.0.0-beta7 [ERROR]   
EntityFramework.SqlServer 7.0.0-beta7 [ERROR]   
Microsoft.AspNet.Authentication.Cookies 1.0.0 [ERROR] -beta7 [ERROR]  
Microsoft.AspNet.Authentication.Facebook 1.0.0-beta7 [ERROR]   
Microsoft.AspNet.Authentication.Google 1.0.0-beta7 [ERROR]   
Microsoft.AspNet.Authentication.MicrosoftAccount 1.0.0-beta7 [ERROR]  
Microsoft.AspNet.Authentication.Twitter 1.0.0-beta7 [ERROR]   
Microsoft.AspNet.Diagnostics 1.0.0-beta7 [ERROR]   
Microsoft.AspNet.Diagnostics.Entity 7.0.0-beta7 [ERROR]   
Microsoft.AspNet.Identity.EntityFramework 3.0.0-beta7 [ERROR]   
Microsoft.AspNet.Mvc 6.0.0-beta7 [ERROR]   
Microsoft.AspNet.Mvc.TagHelpers 6.0.0-beta7 [ERROR]   
Microsoft.AspNet.Server.IIS 1.0.0-beta7 [ERROR]   
Microsoft.AspNet.Server.WebListener 1.0.0-beta7 [ERROR]   
Microsoft.AspNet.StaticFiles 1.0.0-beta7 [ERROR]   
Microsoft.AspNet.Tooling.Razor 1.0.0-beta7 [ERROR]   
Microsoft.Framework.Configuration.Abstractions 1.0.0-beta7 [ERROR]   
Microsoft.Framework.Configuration.Json 1.0.0-beta7 [ERROR]   
Microsoft.Framework.Configuration.UserSecrets 1.0.0-beta7 [ERROR]   
Microsoft.Framework.Logging 1.0.0-beta7 [ERROR]   
Microsoft.Framework.Logging.Console 1.0.0-beta7 [ERROR]   
Microsoft.Framework.Logging.Debug 1.0.0-beta7 [ERROR]   
Microsoft.VisualStudio.Web.BrowserLink.Loader 14.0.0-beta7 [ERROR] 
[ERROR]
C:'XXX'XXX'src'XXX'project.lock.json(1,0):
error: The expected lock file doesn't exist. Please run "dnu restore"
to generate a new lock file. [ERROR] Current runtime target framework:
'DNXCore,Version=v5.0 (dnxcore50)' [ERROR]  Version:     
1.0.0-beta7-15532 [ERROR]  Type:         CoreCLR [ERROR]  Architecture: x64 [ERROR]  OS Name:      Windows [ERROR]  OS Version: 
6.1 [ERROR]  [ERROR]    at Microsoft.Dnx.Runtime.DefaultHost.GetEntryPoint(String
applicationName) [ERROR]    at
Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host,
String applicationName, String[] args) [ERROR]    at
Microsoft.Dnx.ApplicationHost.Program.Main(String[] args) [ERROR] ---
End of stack trace from previous location where exception was thrown
--- [ERROR]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [ERROR]
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly
assembly, String[] args, IServiceProvider serviceProvider) [ERROR]   
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args,
IRuntimeEnvironment env, FrameworkName targetFramework) [ERROR]    at
Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args,
FrameworkName targetFramework) [ERROR]    at
Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args,
FrameworkName targetFramework) [ERROR]

给定

[ERROR]
C:'XXX'XXX'src'XXX'project.lock.json(1,0):
error: The expected lock file doesn't exist. Please run "dnu restore"
to generate a new lock file.

I have try run

PS C:'XXX'XXX> dnu restore
Microsoft .NET Development Utility CoreCLR-x64-1.0.0-beta7-15532
CACHE https://api.nuget.org/v3/index.json Restoring packages for
C:'XXX'XXX'src'XXX'project.json   CACHE
https://api.nuget.org/v3-flatcontainer/system.threading.threadpool/index.json
GET
https://api.nuget.org/v3-flatcontainer/system.net.sockets/index.json  
OK
https://api.nuget.org/v3-flatcontainer/system.net.sockets/index.json
1117ms Writing lock file
C:'XXX'XXX'src'XXX'project.lock.json Restore
complete, 2071ms elapsed
NuGet Config files used:
    C:'Users'XXX'AppData'Roaming'NuGet'NuGet.Config
    C:'XXX'XXX'NuGet.Config
Feeds used:
    https://api.nuget.org/v3-flatcontainer/

似乎成功地重新创建了project.lock.json(时间戳也反映了这一点)。但是,当我尝试再次运行scaffold脚本时,它继续显示上面所示的相同错误,包括"期望的锁文件不存在"部分。

你知道怎么回事吗?

预期的锁文件不存在.请执行命令"dnu restore""在我做完之后

我遇到了同样的问题,并通过:-右击"参考资料"-选择"Restore Packages"

或者Ctrl + shift + R

它将创建/更新"project.lock"。json"文件,其中包含应用程序正在使用的所有NuGet包的完整列表。在我看来,你不应该把它放在源代码控制

试试这个:

关闭Visual Studio 完全

打开Visual Studio命令提示符窗口

cd C:'XXX'XXX'src'XXX'
dnu restore
dnx ef dbcontext scaffold "ConnectionString" EntityFramework.SqlServer

如果您在当前在Windows Server内核环境中执行的应用程序上运行此命令,Core 5.0将无法正常工作。它可以读取一些,但不能创建,特别是如果您在IIS中托管。我经常遇到这个问题,我发现最好跳过EntityFramework。命令,并跳转到

"frameworks":{
    "dnx451":{
          "dependencies":{
                 "EntityFramework.Commands":"7.0.0-beta7"
          }
      }
  ,"dnxcore50"...

同时,确保当你准备运行dnx时,运行

dnvm use latest -r clr -arch {your server kernel arch} x64|x86

以确保您没有试图为命令调用coreclr。这应该可以解决这个问题,对于我来说,它已经在生产服务器上(因为搭建dbcontext基本上是无害的)

我有同样的问题,试图删除引用并重新添加它们,但失败了。我去了ManageNugetPackage管理器,从设置中删除了私有的内部nuget资源,并恢复了我的包,它工作了(我还删除了旧项目)。锁文件)

我发现如果您在UNC路径上创建visual studio解决方案文件夹,则会发生此错误。

当在虚拟机上使用windows(例如Parallels for Mac)时,UNC路径通常会映射您的Documents文件夹,因此visual studio将默认使用此路径来创建新解决方案。

为了解决这个问题,我将visual studio解决方案文件夹移到虚拟机磁盘驱动器中,然后重新打开项目。

我在VS 2015中遇到过类似的问题,抱怨AspNetCore引用的恢复失败,其中一个错误消息指向做"。net恢复"。在最后步骤中,Dotnet恢复失败。但是,

解决方案是使用nuget包管理器设置删除本地nuget包提要引用。