dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.27k stars 5.9k forks source link

LangVersion in solution with C# and VB projects #36919

Open Drake53 opened 1 year ago

Drake53 commented 1 year ago

The docs mention using a Directory.Build.props file to configure the LangVersion of multiple projects. However, in a solution with both C# and visual basic projects, the possible LangVersion values for C# are incompatible with those for VB. For example, if I try setting the C# LangVersion to 8.0 (which is required to enable NRT in .NET framework), I will get a build error in the VB projects.

It would be nice if the docs could mention this possible issue, and provide a solution if one exists. For example, is there a condition that can be placed on the PropertyGroup that only evaluates to true for C# projects?

As a workaround, I put all VB projects in a separate directory with an empty Directory.Build.props file.

Relevant docs: https://github.com/dotnet/docs/blob/26e2e8bedfa72ae518de2b7e617850dd2c6d9d77/docs/csharp/language-reference/configure-language-version.md#configure-multiple-projects https://github.com/dotnet/docs/blob/26e2e8bedfa72ae518de2b7e617850dd2c6d9d77/docs/visual-basic/language-reference/configure-language-version.md#configure-multiple-projects

edit by @billwagner: Add document block.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

BillWagner commented 1 year ago

closing and reopening to run the labeler