sdk: dotnet sln add returns 'Project 'foo.csproj' has an unknown project type and cannot be added to the solution file. Please contact your SDK provider for support.'

Steps to reproduce

  1. Create a new SDK project (dotnet new console is fine)
  2. Change the csproj so that it targets more than one framework (<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>, for example)
  3. Create a new solution using the CLI (dotnet new sln)
  4. Try to add the project from step 1 to the solution created in step 3 (dotnew sln <sln> add <csproj>)

Expected behavior

  • Project 'foo.csproj' added to the solution.
  • Project is added to the solution

Actual behavior

  • Project 'foo.csproj' has an unknown project type and cannot be added to the solution file. Please contact your SDK provider for support.
  • Project is not added to the solution

More details

dotnet build on the project just works, so it doesn’t look like an issue with targeting packs.

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.300
 Commit:    adab45bf0c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.300\

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  1.1.9 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 25 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I can reproduce. Apparently the default MSBuild props isn’t defaulting the project type guids for a multi-targeted project. We may need a fix on their side, as the command is now relying on MSBuild to default the type so that we don’t blindly assign everything to be a C# project that’s missing one like we were doing previously.

Thanks @heemskerkerik for first reporting this issue. A fix has been made to the 2.1.4xx branch and should ship in the upcoming 2.1.400 version of the .NET Core SDK. As such, I’m closing this issue as fixed. Please re-open if you have any questions or concerns. Thanks!

@peterhuene Can confirm that adding <DefaultProjectTypeGuid>FAE04EC0-301F-11D3-BF4B-00C04F79EFBC</DefaultProjectTypeGuid> works in 2.1.300.