为什么我不能让Suave在VS 2017上工作? [英] Why can't I get Suave to work on VS 2017?
问题描述
我在 https://channel9上观看了视频. msdn.com/Shows/Visual-Studio-Toolbox/Visual-F-Tools ,其中创建了使用Suave的项目.我试图完全按照所执行的操作进行操作,但是今天刚刚更新的VS 2017安装的行为却大不相同.
首先,我完全按照视频中的方式安装了Suave,就像在视频中一样,它出现在我的引用中,在mscorlib
和System
之间.
然后视频显示以下代码:
[<EntryPoint>]
let main argv =
startWebServer
0 // return an integer exit code
此时VS 2017建议在视频中显示"Open Suave",因为无法识别startWebServer.我在编辑器的文件Program.fs
中复制了相同的代码.出现错误消息未定义值或构造函数'startWebServer'",但是当光标悬停在左侧黄色区域时,没有任何建议. (也许是因为我正在使用Community Edition?)
无论如何,我在代码中添加了open Suave
,所以我拥有了:
open Suave
[<EntryPoint>]
let main argv =
startWebServer
0 // return an integer exit code
这时,我在Suave下得到一个红色的花样,并且出现错误消息未定义名称空间或模块'Suave'."
如果我在解决方案资源管理器中右键单击Suave,然后选择发送到交互式",则可以在F#Interactive中打开Suave
.
我可以毫无问题地安装和使用Deedle等其他软件包.
关于什么是错的任何想法?
当然可以,但这可能只是一点工作:
如有必要,您应该能够克隆我的存储库.您会注意到,我的fsprojects文件未引用FSharp.Core的显式版本,因此目标版本和实际版本之间没有混淆.实际上是FSharp.Core 4.1 btw.
如果您使用的是原始解决方案,那么我会先做一个新的解决方案.
- 将项目设置为.NET 4.6.2(或您喜欢的任何版本)
- 目标F#4.1
- Nuget Suave
添加这一点,nuget将下载FSharp.Core并将其替换为您的项目.那不是很好.
- 从您的引用中删除FSharp.Core
- 从Nuget中添加FSharp.Core 4.1
您很好:
我还建议您为VS2017安装 Paket .然后,您可以从VS中的工具"菜单中访问它.这样,您只需将Suave和FSharp.core添加到您的paket.references和依赖项文件中,设置redirects: on
,从菜单中运行Paket install并忽略所有此版本不匹配的业务.如果您使用了很多fsx文件,这会特别好,因为paket将从路径中删除版本号.请查看GitHub解决方案中的paket.dependencies和paket.references文件:
paket.dependencies:
framework: = net462
source https://www.nuget.org/api/v2
redirects: on
nuget Suave
项目文件夹中的
paket.references:
Suave
FSharp.Core
I saw a video on https://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Visual-F-Tools where a project using Suave is created. I tried to follow exactly what was being done but my installation of VS 2017, just updated today, behaves quite differently.
First I installed Suave exactly like in the video, and it appears among my references, between mscorlib
and System
, just like in the video.
Then the video shows the following code:
[<EntryPoint>]
let main argv =
startWebServer
0 // return an integer exit code
At this point VS 2017 suggests "Open Suave" in the video, since startWebServer is not recognized. I copied the same code in my editor, in the file Program.fs
. There is an error message "The value or constructor 'startWebServer' is not defined" but there are no suggestions when the cursor hovers on the left yellow area. (Maybe that is because I am using Community Edition?)
In any case, I added open Suave
to the code so I had:
open Suave
[<EntryPoint>]
let main argv =
startWebServer
0 // return an integer exit code
At this point I get a red squiggle under Suave and the error message "The namespace or module 'Suave' is not defined."
If I right-click on Suave in the Solution Explorer and then choose "Send to Interactive" then I can open Suave
in F# Interactive.
I can install and use other packages like Deedle with no problems.
Any ideas on what is wrong?
Of course, you can but it might be just a little work:
You should be able to clone my repo if necessary. You will note that my fsprojects file does not reference an explicit version of FSharp.Core so there is no confusion between the Target and actual version. It's actually FSharp.Core 4.1 btw.
If you're working from your original solution I would make a new one first.
- Set the project to .NET 4.6.2 (or whatever you fancy)
- Target F# 4.1
- Nuget Suave
Add this point nuget will download FSharp.Core and replace it in your project. That's not very nice.
- Delete FSharp.Core from your references
- From Nuget add FSharp.Core 4.1
You're good to go:
I also suggest you install Paket for VS2017. You can then access it from the Tools menu in VS. That way you can just add Suave and FSharp.core to your paket.references and dependencies file, set redirects: on
, run Paket install from the menu and forget about all this version mismatch business. If you're using a lot of fsx files, this is extra nice because paket will strip out the version numbers from the path. Please look at the paket.dependencies and paket.references file in the solution on GitHub:
paket.dependencies in solution root:
framework: = net462
source https://www.nuget.org/api/v2
redirects: on
nuget Suave
paket.references in project folder:
Suave
FSharp.Core
这篇关于为什么我不能让Suave在VS 2017上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!