在Mac/Linux/Windows上編譯corefx遇到的問題及解決方案

來源:互聯網
上載者:User

標籤:

這兩天嘗試在Mac/Linux/Windows三大平台上編譯.NET跨平台三駕馬車(coreclr/corefx/dnx)之一的corefx(.NET Core Framework),結果三個平台的編譯都失敗了。後來一一都解決了,在這篇博文中分享一下。

(一)

在Mac上編譯corefx遇到的錯誤如下:

/git/dotnet/corefx/dir.props(214,5): warning : The Roslyn targets do not exist- Roslyn will not be used for this build, but the package should be restored if you build again. [/git/dotnet/corefx/src/dirs.proj]/git/dotnet/corefx/dir.props(214,5): warning : The Roslyn targets do not exist- Roslyn will not be used for this build, but the package should be restored if you build again. [/git/dotnet/corefx/src/Microsoft.CSharp/src/Microsoft.CSharp.csproj]/var/folders/c4/lf8cm6lx5178xsswpzfs2f_c0000gn/T/tmp257bf798c8da46a7baf3954722152b21.exec.cmd: line 3: /git/dotnet/corefx/packages/dnx-mono.1.0.0-beta5-11760/bin/dnu: Permission denied/git/dotnet/corefx/packages/Microsoft.DotNet.BuildTools.1.0.25-prerelease-00050/lib/packageresolve.targets(31,5): error MSB3073: The command ""/git/dotnet/corefx/packages/dnx-mono.1.0.0-beta5-11760/bin/dnu" restore --packages "/git/dotnet/corefx/packages" "/git/dotnet/corefx/src/Microsoft.CSharp/src/project.json"" exited with code 126. [/git/dotnet/corefx/src/Microsoft.CSharp/src/Microsoft.CSharp.csproj]...6 Warning(s)5 Error(s)

刪除corefx中packages檔案夾重新編譯,錯誤變成了:

System.IO.InvalidDataException: Unable to read package from path ‘Microsoft.Net.ToolsetCompilers.1.0.0-rc3-20150510-01.nupkg‘. ---> System.IO.FileFormatException: The specified archive is invalid.at System.IO.Packaging.Package.OpenCore (System.IO.Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean ownsStream) <0x1055e4fd0 + 0x001df> in <filename unknown>:0 

再次編譯,又回到了之前的錯誤。

懷疑問題是Mac電腦與NuGet伺服器之間的網路問題引起的,於是從另外一台Linux伺服器上將corefx所需的所有packages下載下來之後,編譯就取得了成功。

scp -r [email protected]:/git/corefx/packages/ /git/dotnet/corefx
./build.sh...    1 Warning(s)    0 Error(s)Time Elapsed 00:07:33.93Build Exit Code = 0

(二)

在Linux CentOS上編譯corefx遇到的錯誤如下:

Restoring MSBuild...WARNING: Error: SendFailure (Error writing headers)WARNING: Error: SendFailure (Error writing headers)WARNING: The request timed outWARNING: Error: SendFailure (Error writing headers)Unable to find version ‘14.1.0.0-prerelease‘ of package ‘Microsoft.Build.Mono.Debug‘.Failed to restore MSBuild.

這個問題是由於沒有在Linux上安裝根憑證,無法以https訪問nuget伺服器,運行下面的命令就可以解決問題:

mozroots --import --sync

(三)

在Windows上編譯corefx遇到的錯誤如下(電腦上安裝的是Visual Studio 2015):

corefx\src\Common\src\System\SR.cs(19,67): error CS0117: ‘SR‘ does not contain a definition for ‘ResourceType‘ [corefx\src\Microsoft.CSharp\src\Microsoft.CSharp.csproj]...

這個問題比較怪,竟然是前段時間編譯corefx時在bin檔案夾產生的檔案引起的,刪除corefx中的bin檔案夾,重新編譯,問題就消失了。

【相關連結】

Build fails on Mac/Linux/Windows

在Mac/Linux/Windows上編譯corefx遇到的問題及解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.