I created a new .NET 6 worker service project with dotnet new worker -n MyProject. I then created a new solution with dotnet sln new -n MySolution. Finally I added the project to the solution with dotnet sln add .\MyProject\MyProject.csproj. When I opened the solution in Visual Studio 2022, I was greeted with a bunch of "errors" in the default Worker.cs file:
The project will build and run just fine. The problem appears to be with the new Implicit Usings feature of .NET 6. Visual Studio is not recognizing that the red-underlined items are implicitly imported from their namespaces, and don't have to be referenced manually. There is an additional error in the error list:
Project "C:\LongDirectoryPathHere\MyProject\obj\MyProject.csproj.nuget.g.targets" was not imported by "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.targets" at (35,3), due to the file not existing.
I checked and the file does indeed exist.
Apart from being quicker to use, the reason I use dotnet new instead of creating the solution/project in Visual Studio is that Visual Studio complains about long paths and refuses to create projects that would output files with a path length over 259 characters, despite Windows 10 supporting paths that are thousands of characters long. The full path to the "missing" file is exactly 261 characters.
Is this caused by the max path issue, or is it something else?
