zoukankan      html  css  js  c++  java
  • 在Mac/Linux/Windows上编译corefx遇到的问题及解决方法

    这两天尝试在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):

    corefxsrcCommonsrcSystemSR.cs(19,67): error CS0117: 
    'SR' does not contain a definition for 'ResourceType' 
    [corefxsrcMicrosoft.CSharpsrcMicrosoft.CSharp.csproj]
    ...

    这个问题比较怪,竟然是前段时间编译corefx时在bin文件夹生成的文件引起的,删除corefx中的bin文件夹,重新编译,问题就消失了。

    【相关链接】

    Build fails on Mac/Linux/Windows

  • 相关阅读:
    我的知识库(4) java获取页面编码(Z)
    知识库(3)JAVA 正则表达式 (超详细)
    The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts
    某人总结的《英语听力的技巧 》,挺搞的
    我的知识库(5)java单例模式详解
    构建可扩展程序
    SerialPort (RS232 Serial COM Port) in C# .NET
    Python学习笔记——String、Sequences
    UI题目我的答案
    jQuery学习系列学会操纵Form表单元素(1)
  • 原文地址:https://www.cnblogs.com/dudu/p/build-corefx-on-mac-linux-windows.html
Copyright © 2011-2022 走看看