找不到dotnet手表和'Microsoft.NETCore.App'版本'1.1.0-preview1-001100-00'的奥秘

dotnet watch says "specified framework not found"

WARNING: This post is full of internal technical stuff. I think it's interesting and useful. You may not.

警告:这篇文章充满了内部技术资料。 我认为这很有趣且有用。 你不可以。

I had an interesting Error/Warning happen when showing some folks .NET Core recently and I thought I'd deconstruct it here for you, Dear Reader, because it's somewhat multi-layered and it'll likely help you. It's not just about Core, but also NuGet, Versioning, Package Management in general, version pinning, "Tools" in .NET Core, as well as how .NET Runtimes work and version. That's a lot! All that from this little warning. Let's see what's up.

最近,当向某些人展示.NET Core时,我发生了一个有趣的错误/警告,我想在这里为您解构它,亲爱的读者,因为它有些多层,并且可能会为您提供帮助。 它不仅与Core有关,而且与NuGet,版本控制,一般的包管理,版本固定,.NET Core中的“工具”以及.NET运行时的工作方式和版本有关。 好多啊! 所有这些都来自这个小警告。 让我们看看发生了什么。

First, let's say you have .NET Core installed. You likely got it from http://dot.net and you have either 1.0.0 or the 1.0.1 update.

首先,假设您已安装.NET Core。 您可能是从http://dot.net获得的,并且具有1.0.0或1.0.1更新。

Then say you have a website, or any app at all. I made one with "dotnet new -t web" in an empty folder.

然后说您拥有一个网站,或者根本没有任何应用程序。 我在一个空文件夹中使用“ dotnet new -t web”制作了一个。

I added "dotnet watch" as a tool in the project.json like this. NOTE the "1.0.0-*" there.

我像这样在project.json中添加了“ dotnet watch”作为工具。 注意那里的“ 1.0.0- *”。

"tools": {
"Microsoft.DotNet.Watcher.Tools": "1.0.0-*"
}

dotnet watch is nice because it watches the source code underneath it while running your app. If you change your code files, dotnet-watch will notice, and exit out, then launch "dotnet run" (or whatever, even test, etc) and your app will pick up the changes. It's a nice developer convenience.

dotnet watch很不错,因为它在运行应用程序时会监视其下面的源代码。 如果您更改代码文件,则dotnet-watch会注意到并退出,然后启动“ dotnet run”(或其他方法,甚至进行测试等),您的应用程序将获取这些更改。 这是开发人员的便利。

I tested this out on last weekend and it worked great. I went to show some folks on Monday that same week and got this error when I typed "dotnet watch."

我在上周末进行了测试,效果很好。 我在同一周的星期一去向一些人展示当我键入“ dotnet watch ”时出现了此错误

C:\Users\scott\Desktop\foofoo>dotnet watch
The specified framework 'Microsoft.NETCore.App', version '1.1.0-preview1-001100-00' was not found.
- Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet\shared\Microsoft.NETCore.App
- The following versions are installed:
1.0.0
1.0.1
- Alternatively, install the framework version '1.1.0-preview1-001100-00'.

Let's really look at this. It says "the specified framework...1.1.0" was not found. That's weird, I'm not using that one. I check my project.json and I see:

让我们真正看一下。 它说“找不到指定的框架... 1.1.0”。 太奇怪了,我没有使用那个。 我检查了我的project.json,发现:

"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},

So who wants 1.1.0? I typed "dotnet watch." Can I "dotnet run?"

那么谁想要1.1.0? 我输入了“ dotnet watch” 。 我可以“运行dotnet吗?”

C:\Users\scott\Desktop\foofoo>dotnet run
Project foofoo (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
Compiling foofoo for .NETCoreApp,Version=v1.0
Hosting environment: Production
Content root path: C:\Users\scott\Desktop\foofoo
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

Hey, my app runs fine. But if I "dotnet watch" I get an error.

嘿,我的应用程序运行正常。 但是,如果我“ dotnet watch ”,我会得到一个错误。

Remember that dotnet watch and other "tools" like it are not dependencies per se, but helpful sidecar apps. Tools can watch, squish css and js, precompile views, and do general administrivia that isn't appropriate at runtime.

请记住,dotnet watch和其他类似的“工具”本身并不是依赖项,而是有用的sidecar应用程序。 工具可以监视,压缩CSS和JS,预编译视图以及执行运行时不适合的常规管理。

It seems it's dotnet watch that wants something I don't have.

似乎是dotnet手表想要我没有的东西。

Now, I could go install the framework 1.1.0 that it's asking for, and the error would disappear, but would I know why? That would mean dotnet watch would use .NET Core 1.1.0 but my app (dotnet run) would use 1.0.1. That's likely fine, but is it intentional? Is it deterministic and what I wanted?

现在,我可以去安装它所要求的框架1.1.0,错误将消失,但是我知道为什么吗? 这意味着dotnet watch将使用.NET Core 1.1.0,但是我的应用程序(dotnet运行)将使用1.0.1。 可能不错,但这是故意的吗? 它是确定性的,我想要什么?

I'll open my generated project.lock.json. That's the calculated tree of what we ended up with after dotnet restore. It's a big calculated file but I can easily search it. I see two things. The internal details aren't interesting but version strings are.

我将打开生成的project.lock.json。 这就是dotnet还原后最终得到的结果的计算树。 这是一个很大的计算文件,但我可以轻松地搜索它。 我看到两件事。 内部细节并不有趣,但是版本字符串却很有趣。

First, I search for "dotnet.watcher" and I see this:

首先,我搜索“ dotnet.watcher”,然后看到以下内容:

"projectFileToolGroups": {
".NETCoreApp,Version=v1.0": [
"Microsoft.AspNetCore.Razor.Tools >= 1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools >= 1.0.0-preview2-final",
"Microsoft.DotNet.Watcher.Tools >= 1.0.0-*",
"Microsoft.EntityFrameworkCore.Tools >= 1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools >= 1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools >= 1.0.0-preview2-final"
]

Ah, that's a reminder that I asked for 1.0.0-*. I asked for STAR for dotnet-watch but everything else was very clear. They were specific versions. I said "I don't care about the stuff after 1.0.0 for watch, gimme whatever's good."

嗯,这提醒我我要求1.0.0- *。 我要求STAR进行dotnet监视,但其他所有内容都非常清楚。 它们是特定版本 我说:“我不关心1.0.0之后的东西,给我看,不管怎么样。”

It seems that a new version of dotnet-watch and other tools came out between the weekend and my demo.

在周末和我的演示之间,似乎出现了新版本的dotnet-watch和其他工具。

Search more in project.lock.json and I can see what all it asked for...I can see my dotnet-watch's dependency tree.

在project.lock.json中搜索更多内容,我可以看到它的全部要求...我可以看到我的dotnet-watch的依赖关系树。

"tools": {
".NETCoreApp,Version=v1.0": {
"Microsoft.DotNet.Watcher.Tools/1.0.0-preview3-final": {
"type": "package",
"dependencies": {
"Microsoft.DotNet.Cli.Utils": "1.0.0-preview2-003121",
"Microsoft.Extensions.CommandLineUtils": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging.Console": "1.1.0-preview1-final",
"Microsoft.NETCore.App": "1.1.0-preview1-001100-00"
},

Hey now. I said "1.0.0-*" and I ended up with "1.0.0-preview3-final"

嘿,现在。 我说“ 1.0.0- *”,结果却是“ 1.0.0-preview3-final”

Looks like dotnet-watch is trying to bring in a whole new .NET Core. It wants 1.1.0. This new dotnet-watch is part of the wave of new preview stuff from 1.1.0.

似乎dotnet-watch正在尝试引入一个全新的.NET Core。 它想要1.1.0。 这款新的dotnet-watch是1.1.0版本中新预览内容浪潮的一部分。

But I want to stay on the released and supported "LTS" (long term support) stuff, not the new fancy builds.

但是我想继续使用已发布并受支持的“ LTS”(长期支持)产品,而不是新的花哨的版本。

I shouldn't have used 1.0.0-* as it was ambiguous. That might be great for my local versions or when I intend to chase the latest but not in this case.

我不应该使用1.0.0- *,因为它是模棱两可的。 这对于我的本地版本或当我打算追求最新版本(而不是这种情况)时可能很棒。

I updated my version in my project.json to this and did a restore.

我将project.json中的版本更新为此,并进行了还原。

"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final",

Now I can reliably run dotnet restore and get what I want, and both dotnet watch and dotnet run use the same underlying runtime.

现在,我可以可靠地运行dotnet restore并获得所需的内容,并且dotnet watch和dotnet run都使用相同的基础运行时。

翻译自: https://www.hanselman.com/blog/the-mystery-of-dotnet-watch-and-microsoftnetcoreapp-version-110preview100110000-was-not-found

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值