Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch-to-projects: the project 'path/myproject.csproj' could not be loaded. Not a project... #61

Open
lucaritossa opened this issue Jan 20, 2020 · 16 comments

Comments

@lucaritossa
Copy link

lucaritossa commented Jan 20, 2020

A couple of months ago it worked.
Now I'm receiving this error:

The project 'path/myproject.csproj' could not be loaded: Not a project: path\myproject.csproj

I'm using DNT v1.3.1.0, installed via dotnet tool install -g dnt
Current workaround is to reinstall DNT using npm: npm i -g dotnettools

"myproject.csproj" is an ASP.NET MVC Visual Studio Project that is using .NET Framework 4.6.1

Here it is a snippet of my .csproj file

    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>

In my solution I have also other types of .csproj (class and library) that are correctly switched.

@RicoSuter
Copy link
Owner

I think dotnet tool install -g dnt installs DNT as global tool. Global tools only support .NET Core as runtime and maybe this is why loading full .NET Framework (4.6.1) projects cannot be loaded? The npm version also contains a full .net version.

@RicoSuter
Copy link
Owner

Probably a regression from this PR:
#53

/cc @0x15e

@0x15e
Copy link
Contributor

0x15e commented Jan 20, 2020

@RicoSuter I don't know why but I thought you reverted that PR because it was causing a build to fail.

@lucaritossa Which dotnet core SDKs and runtimes do you have installed? Which Visual Studio are you using and which frameworks and targeting packs are installed? Are you using the npm that came with VS or did you install it separately (and which version)?

I have a Windows system available to me now so rework will be much easier than before.

@RicoSuter
Copy link
Owner

I don't know why but I thought you reverted that PR because it was causing a build to fail.

No i didnt, i think i'm using an older version in my builds for now. But we need a fix which works for all ( :-) ) scenarios eventually.

@lucaritossa
Copy link
Author

Which dotnet core SDKs and runtimes do you have installed?

This is my dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.1.101
 Commit:    b377529961

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

Host (useful for support):
  Version: 3.1.1
  Commit:  a1388f194c

.NET Core SDKs installed:
  1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
  1.0.0 [C:\Program Files\dotnet\sdk]
  1.0.2 [C:\Program Files\dotnet\sdk]
  1.0.3 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  1.1.9 [C:\Program Files\dotnet\sdk]
  1.1.10 [C:\Program Files\dotnet\sdk]
  1.1.11 [C:\Program Files\dotnet\sdk]
  1.1.12 [C:\Program Files\dotnet\sdk]
  1.1.13 [C:\Program Files\dotnet\sdk]
  1.1.14 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.0.3 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.100 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.400 [C:\Program Files\dotnet\sdk]
  2.1.401 [C:\Program Files\dotnet\sdk]
  2.1.402 [C:\Program Files\dotnet\sdk]
  2.1.403 [C:\Program Files\dotnet\sdk]
  2.1.500 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.1.504 [C:\Program Files\dotnet\sdk]
  2.1.505 [C:\Program Files\dotnet\sdk]
  2.1.507 [C:\Program Files\dotnet\sdk]
  2.1.508 [C:\Program Files\dotnet\sdk]
  2.1.509 [C:\Program Files\dotnet\sdk]
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.1.802 [C:\Program Files\dotnet\sdk]
  2.2.107 [C:\Program Files\dotnet\sdk]
  3.1.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [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 1.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [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.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Which Visual Studio are you using and which frameworks and targeting packs are installed?

Visual Studio 2019 v16.4.3
My project is targeting .NET Framework 4.6.1

Are you using the npm that came with VS or did you install it separately (and which version)?

No, I'm using npm installed with node.js.
npm v6.9.0.

@0x15e
Copy link
Contributor

0x15e commented Jan 22, 2020

@lucaritossa Thanks for the info. I'll get a test environment put together and start working on reproducing the problem. I may not have time until the weekend because of work responsibilities. Hopefully that's not too much of a problem because there's a workaround.

@RicoSuter
Copy link
Owner

Npm version should not matter it just looks up the available .net fws and runs the .net cli app

@lucaritossa
Copy link
Author

@0x15e don’t worry, there is no hurry!

@huylethanh
Copy link

I got this issue as well.

@0x15e
Copy link
Contributor

0x15e commented Feb 3, 2020

@huylethanh Can you see anything different about your projects compared to @lucaritossa's? If so, what?

@RicoSuter
Copy link
Owner

Please report what binary you use (full .net/.net core via global tool or npm).

@RicoSuter
Copy link
Owner

RicoSuter commented Feb 13, 2020

Can you retry with v1.4.0 (added more TFs and updated MSBuild pkgs)?

@0x15e
Copy link
Contributor

0x15e commented Feb 14, 2020

I haven't forgotten about this. I've been looking over things for the past couple of days whenever I can scrape a couple of minutes together.

@lucaritossa Would it be possible for you to submit a simplified solution with projects (no actual source is required) that I could use to reproduce this?

@RicoSuter I'm not sure more TFs or updated msbuild packages are going to be helpful here. If anything, it might be good to simplify things. For example, the conditional versioning on the msbuild packages might actually be hurting things. I'm going to experiment with just using the 15.9.x versions and targeting the Commands project at netstandard2.0. Because the msbuild packages aren't supposed to be distributed anyway, this may help with backwards compatibility and preventing msbuild assembly version conflicts.

I'm also considering adding an option to configure which version of MSBuild is used. The way I have the locator working right now is the "default" easy way where it finds everything and then uses the newest one.

I may change this behavior to something more flexible like this:

  • Check the command line for a parameter like --msbuild-instance-prompt. If it's not present, use the current behavior where MSBuildLocator.RegisterDefaults() is called and the default instance is used. Alternatively, it might be better to invert this behavior and have the user pass a parameter if they don't want to be prompted (i.e., they want to use the default).
  • Execute MSBuildLocator.QueryVisualStudioInstances().
  • If only one instance is found, use that.
  • If multiple instances were found, check if the user specified which one to use either by command line parameter (maybe --msbuild-instance-path) or in the config json (switcher.json) file (maybe a property called "msbuildInstancePath"). If one of those is configured and matches one of the found instances, use the configured instance.
  • If there is still no instance configured, present a simple prompt on the console like the one in this example so the user can select an instance.

What are your thoughts on this?

@lucaritossa
Copy link
Author

@0x15e here it is
example.zip

The zip file contains 2 folder:

  • MyNugetLibrarySolution: contains the source code of an empty class library that I already published to nuget.org "Ritossa.DntExample.MyLibrary"
  • MyApplicationSolution: contains an ASP.NET MVC web application that use the example nuget package "Ritossa.DntExample.MyLibrary". Use the file switcher.json to switch between packages and projects.

Both are target .NET Framework 4.6.1
In my environment I reproduced the same error of this issue (occurs when using DNT as global tools, all ok using npm)

Hope this helps!

@JohnGoldInc
Copy link

JohnGoldInc commented Sep 11, 2020

I have same problem, figure anything out yet?

@JohnGoldInc
Copy link

Solved my problem by uninstalling via npm method, reinstalling via dotnet method (had tried uninstall/reinstall via npm, with no success).

I think I got into the mess by installing via both methods when I was reading my companies readme on the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants