文章出處
文章列表
這兩天嘗試在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 root@server:/git/corefx/packages/ /git/dotnet/corefx
./build.sh ... 1 Warning(s) 0 Error(s) Time Elapsed 00:07:33.93 Build Exit Code = 0
(二)
在Linux CentOS上編譯corefx遇到的錯誤如下:
Restoring MSBuild... WARNING: Error: SendFailure (Error writing headers) WARNING: Error: SendFailure (Error writing headers) WARNING: The request timed out WARNING: 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文件夾,重新編譯,問題就消失了。
【相關鏈接】
文章列表
全站熱搜
留言列表