使用 C# 7.0 功能时无法构建

Unable to build while using C# 7.0 features

最近我提取了一个项目的最新代码,该项目对一些同事来说编译得很好,但对我来说却不行。代码中有一行简单的代码导致它无法构建:

if (x is null || y is null)
    return false;

给我所有这些编译错误:

) expected 
Type Expected 
; expected 
Type expected 
; expected 
} expected

我觉得这是编译器的问题?我在 Visual Studio 2017 Enterprise 15.6.3, .Net 4.7.03056。该项目引用 Microsoft.Net.Compilers 2.4.0 并在 Properties > Build > Advanced 中设置为 C# latest major version(默认)

我不确定要构建它我缺少什么。将我的环境与同事进行比较似乎是一样的——有什么想法吗?谢谢。

编辑:无法将其更改为 ==,因为它是 == 的覆盖 - 而且这只是避免了这种情况,并没有解决它。

在我的 .csproj 文件中,我有几个流氓 if exists 导入,过去出于某种原因被放置在那里。因为他们不存在于我的同事环境中,所以这对他们来说不是问题。

 <Import Project="..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />
 <Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
 <Import Project="..\..\..\Dependencies\Packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\..\..\Dependencies\Packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
 <Import Project="..\..\..\Dependencies\Packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\..\..\Dependencies\Packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />

我假设因为后面的导入是较低版本,并且碰巧存在,所以它们覆盖了以前的导入。

就是说,我只是删除了最后两个导入,一切正常 - 感谢大家的投入!