question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.'

See original GitHub issue

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]

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
peterhuenecommented, Jun 13, 2018

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.

1reaction
peterhuenecommented, Jul 30, 2018

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet sln command - .NET CLI
The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file.
Read more >
visual studio - `dotnet sln add` wrong project type GUID
The CLI calls into msbuild to get the default project type GUID to use. MSBuild sets the $(DefaultProjectTypeGuid) for C# and VB projects...
Read more >
SonarScanner for .NET - SonarQube Docs
The SonarScanner for .NET is the recommended way to launch an analysis for projects built using MSBuild or dotnet.
Read more >
Dotnet restore vs nuget restore. Share. In my code repo, there
I have a Visual Studio solution and am trying to build to run on a Linux installation ... I am trying to restore...
Read more >
Micro Focus Fortify Static Code Analyzer User Guide
Translating a Single Project from a Visual Studio Solution ... Adding Fortify Static Code Analyzer to your Favorites List.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found