gpt4 book ai didi

c# - "The expected lock file doesn' 存在。请在我这样做后立即运行 "dnu restore"

转载 作者:IT老高 更新时间:2023-10-28 12:54:39 25 4
gpt4 key购买 nike

我正在为所有内容运行 beta7,包括 EF 7。我正在尝试使用 ASP.NET 5 应用程序模板项目连接到我的远程现有数据库。我的 project.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

我不能这样做,因为我遇到了一个已解决的问题,如下所述: Using existing database with ASP.NET 5 and EF7 (beta 7)

现在我终于可以运行命令“dnx”了,但是当我尝试使用我的连接字符串运行它时,它看起来像这样:

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.

我试过运行

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(时间戳也反射(reflect)了这一点)。但是,当我再次尝试运行我的脚手架脚本时,它一直显示上面显示的相同错误,包括“预期的锁定文件不存在”部分。

知道出了什么问题吗?

最佳答案

我遇到了同样的问题,并通过以下方式解决了它:- 右键单击​​“引用”- 选择“恢复包”

或者 Ctrl + Shilf + R

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

关于c# - "The expected lock file doesn' 存在。请在我这样做后立即运行 "dnu restore",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32818884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com