Skip to content

Commit

Permalink
[build] set $(DisableImplicitNamespaceImports) by default (#859)
Browse files Browse the repository at this point in the history
Context: dotnet/sdk#19050

xamarin-android is hitting this build error with .NET 6 Preview 7:

    C:\src\xamarin-android\external\Java.Interop\src\Java.Interop\obj\Debug\net6.0\Java.Interop.ImplicitNamespaceImports.cs(2,1):
    error CS8400: Feature 'global using directive' is not available in C# 8.0. Please use language version 10.0 or greater.
    [C:\src\xamarin-android\external\Java.Interop\src\Java.Interop\Java.Interop.csproj]

In fact, you can reproduce this by doing:

    dotnet new console
    dotnet build -p:LangVersion=8.0

It seems like `@(Import)` item group should not be present unless the
project is C# 10 or higher?

For now, we can set `$(DisableImplicitNamespaceImports)` to workaround
the issue.
  • Loading branch information
jonathanpeppers committed Jul 19, 2021
1 parent 855ecfa commit 4fb7c14
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Directory.Build.props
Expand Up @@ -24,6 +24,8 @@
Condition="Exists('$(_OutputPath)MonoInfo.props')"
/>
<PropertyGroup>
<!-- Workaround: https://github.com/dotnet/sdk/issues/19050 -->
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<AppendTargetFrameworkToOutputPath Condition=" '$(AppendTargetFrameworkToOutputPath)' == '' ">False</AppendTargetFrameworkToOutputPath>
<BaseIntermediateOutputPath Condition=" '$(BaseIntermediateOutputPath)' == '' ">obj\</BaseIntermediateOutputPath>
</PropertyGroup>
Expand Down

0 comments on commit 4fb7c14

Please sign in to comment.