我正在尝试在 mac 环境中使用 mono xbuild 4.2 构建一个 toolversion/targeversion 4.0 项目。我使用以下命令:
xbuild /tv:4.0
我可以在编译错误中看到它似乎仍在使用默认的 4.5 工具版本:
/usr/local/Cellar/mono/4.2.0.179/lib/mono/4.5/Microsoft.CSharp.targets(核心编译目标)->
Helpers/Formatters/TextMediaTypeFormatter.cs(20,32):错误 CS0115:
我检查了 .sln 和 csproj 文件,它们不包含对 4.5 的任何引用,这是 .csproj 的一部分。
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> ... <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
...
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
...
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
...
问题的核心是一个 MediaTypeFormatter 被覆盖的方法,它似乎在 4.0 和 4.5 之间发生了变化,因为它使用了 HttpContent 和 HttpContentHeaders,
我希望通过能够在 csproj 或相关文件中设置工具版本或目标版本,我可以在单声道下构建东西。
我是 C# 和 Mono 的新手,所以任何关于我做错了什么或其他可能的解决方案的见解将不胜感激。
编辑:由于项目限制,不能选择更新到 4.5 工具/目标/版本。