Skip to content

New/Empty Blazor Server Project from template doesn't compile (.Net 6 preview 7) #19652

@Webreaper

Description

@Webreaper

Bug Description

I was trying to produce a repro for another bug (#19653) in preview 7, so created a brand new empty Blazor Server project using the Wizard/Template in VS for Mac 8.10 (latest version). The resulting project doesn't compile.

Screenshot 2021-08-11 at 08 59 31

I tried editing the csproj file to set DisableImplicitNamespaceImports=true, but it still fails to compile due to the missing using statements that I'd now need to add, and the lack of scoping braces for the namespaces.

Expected Behaviour

Creating a new solution from a template should result in a project which compiles and runs without error.

For consideration

The philosophical wisdom of the implicit namespaces change (which is going to break most peoples' projects the first time they attempt to compile with .Net 6, unless they edit every project to disable implicit namespace imports) is probably for another forum. But at the very least, such a fundamental change needs to be accounted for in the templates so that a clean, new project made from a template will compile without error.

As well as fixing it for .Net 6 preview, perhaps a wise decision might be to introduce a new checkbox in the template wizards: "Use backward-compatible namespaces/usings", to generate brace-scoped namespaces and disabling implicit namespaces, so that people who may not have a homogenous environment can create new projects which can be compiled by previous versions of the SDK without major refactoring.

Environment

  • Visual Studio for Mac v8.10.6 (build 10)
  • .Net 6 preview 7 (6.0.100-preview.7.21379.14, x64 version)
  • M1 MacBook Pro running Big Sur 11.5 beta

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions