2016-11-25 59 views
4

我試圖按照https://github.com/enricosada/fsharp-dotnet-cli-samples/wiki/Getting-Started#hello-world的說法開始使用我的mac上的f#和dotnet核心。在帶有dotnet cli的mac上使用f#

 
% mkdir helloworld 
% cd helloworld 
% dotnet new --lang "f#" 
Created new F# project in /Users/User/dotnet/helloworld. 
% ls 
Program.fs project.json 

在這裏,我已經可以告訴你,沒有NuGet.Config,正如我在後面教程中所述。然後

 
% dotnet restore 
log : Restoring packages for /Users/User/dotnet/helloworld/project.json... 
log : Restoring packages for tool 'dotnet-compile-fsc' in /Users/User/dotnet/helloworld/project.json... 
log : Writing lock file to disk. Path: /Users/User/dotnet/helloworld/project.lock.json 
log : /Users/User/dotnet/helloworld/project.json 
log : Restore completed in 2148ms. 
% dotnet run 
Project helloworld (.NETCoreApp,Version=v1.1) will be compiled because expected outputs are missing 
Compiling helloworld for .NETCoreApp,Version=v1.1 
The specified framework 'Microsoft.NETCore.App', version '1.0.0' was not found. 
    - Check application dependencies and target a framework version installed at: 
     /usr/local/share/dotnet/shared/Microsoft.NETCore.App 
    - The following versions are installed: 
     1.1.0 
    - Alternatively, install the framework version '1.0.0'. 
/usr/local/share/dotnet/dotnet compile-fsc @/Users/User/dotnet/helloworld/obj/Debug/netcoreapp1.1/dotnet-compile.rsp returned Exit Code 131 

Compilation failed. 
    0 Warning(s) 
    0 Error(s) 

Time elapsed 00:00:00.4439997 

DOTNET信息說

 
% dotnet --info 
.NET Command Line Tools (1.0.0-preview2-1-003177) 

Product Information: 
Version:   1.0.0-preview2-1-003177 
Commit SHA-1 hash: a2df9c2576 

Runtime Environment: 
OS Name:  Mac OS X 
OS Version: 10.12 
OS Platform: Darwin 
RID:   osx.10.12-x64 
+1

這些指示(頂部)安裝.Net核心預覽版1.但https://github.com/dotnet/cli/releases列出預覽版3,其[發佈公告](https://blogs.msdn.microsoft.com/ dotnet/2016/11/16/announcing-net-core-tools-msbuild-alpha /)提到他們正在從'project.json'和bac k轉換爲'.csproj'格式,儘管它是一個'.csproj'格式,顯然可以大大簡化它的外觀。也許你只需要將.NET CLI工具更新到1.0預覽版3並重試? – rmunn

回答

2

我不得不創建一個使用dotnet new --lang "f#"

的F#項目時之前類似的問題問題是這樣的依賴,你應該在你看到project.json文件: dotnet-compile-fsc

"tools": { 
    "dotnet-compile-fsc": "1.0.0-preview2.1-*" 
}, 

在撰寫本文時,它僅支持.Net Core 1.0。* runtime,而不是您已安裝的.Net Core 1.1。* runtime。

要解決此問題,您可以install the .Net Core 1.0.* runtime from here並再次運行dotnet run。 1.1。*和1.0。*運行時都可以在本地安裝而不會出現問題。

僅供參考here is the issue reported on GitHub。有一個修復,但它不在NuGet。

1

當前的dotnet-compile-fsc不支持.NET Core 1.1(current,sdk preview2.1),只有.NET Core 1.0(LTS,sdk preview2)。

可以解決辦法做dotnet restore像下面,使用開發飼料,因爲新的包還沒有在nuget.org

dotnet restore -f https://www.myget.org/F/netcorecli-fsc-preview2-1/api/v3/index.json

看到https://github.com/dotnet/netcorecli-fsc/wiki/.NET-Core-SDK-preview2.1更多信息/解決方法

相關問題