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

Adding a reference to an esproj from an ASP.Net project results in a NU1105 error #12986

Closed
joj opened this issue Nov 3, 2023 · 4 comments · Fixed by NuGet/NuGet.Client#5590

Comments

@joj
Copy link

joj commented Nov 3, 2023

NuGet Product Used

Visual Studio Package Management UI, Other/NA

Product Version

Latest

Worked before?

17.8

Impact

It's more difficult to complete my work

Repro Steps & Context

When creating a new ASP.Net project, if we add a new JavaScript project and reference it from ASP.Net, we get this error:
NU1105  Unable to find project information for 'C:\Users\daroth\Documents\GitHub\javiercn\EsprojPlusWebAppIntegration\EsprojPlusWebAppIntegration.Assets\EsprojPlusWebAppIntegration.Assets.esproj'. If you are using Visual Studio, this may be because the project is unloaded or not part of the current solution so run a restore from the command-line. Otherwise, the project file may be invalid or missing targets required for restore.

I'm attaching a sample project and a binlog that shows the issue. Restoring from command line fixes the issue, but that's not really possible from within Visual Studio. This behavior seems new, only happening on internal versions of VS at the moment.

binlog.zip
EsprojPlusWebAppIntegration.zip

@nkolev92
Copy link
Member

nkolev92 commented Nov 4, 2023

Thanks for the details @joj

This seems to be something that hasn't worked since 17.7.0.
I also tried with Version 17.8.0 Preview 3.0 and Version 17.8.0 Preview 5.0, and the behavior is the same.

There's no regression as far as I can tell, but I think I can also explain why it used to work but doesn't work that well now.
If the obj folder has been created locally, then everything will work.

The root cause is kind of captured here: https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1105#visual-studio.

NuGet has an optimization to work with "unloaded projects", it'll read the previously generated data from the commandline.

In VS, the project system for esproj is not reporting any capabilities that NuGet would need to get the project information so NuGet can't read it, so it basically treats it as unloaded.

In order to get the equivalent experience on the commandline and VS, we need to either get NuGet to recognize this project, or update the project system for esproj to report that it has the capabilities NuGet needs to get project information.

@nkolev92
Copy link
Member

nkolev92 commented Nov 4, 2023

The fix might be as simple as adding the project guid to the supported project types:

For example, me making this change:

diff --git a/src/NuGet.Clients/NuGet.VisualStudio.Common/ProjectType.cs b/src/NuGet.Clients/NuGet.VisualStudio.Common/ProjectType.cs
index 666b0ac8c..9e309ea9d 100644
--- a/src/NuGet.Clients/NuGet.VisualStudio.Common/ProjectType.cs
+++ b/src/NuGet.Clients/NuGet.VisualStudio.Common/ProjectType.cs
@@ -27,6 +27,7 @@ public static class ProjectType
             VsProjectTypes.DeploymentProjectTypeGuid,
             VsProjectTypes.CosmosProjectTypeGuid,
             VsProjectTypes.ManagementPackProjectTypeGuid,
+            "{54a90642-561a-4bb1-a94e-469adee60c69}"
         };

         private static readonly HashSet<string> Unsupported = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
@@ -46,6 +47,7 @@ public static class ProjectType
             VsProjectTypes.NomadForVisualStudioProjectTypeGuid,
             VsProjectTypes.DxJsProjectTypeGuid,
             VsProjectTypes.CosmosProjectTypeGuid,
+            "{54a90642-561a-4bb1-a94e-469adee60c69}"
         };

         // List of project types that cannot have references added to them

seem to make things work.

However, this needs further testing.

The relevant code is: https://github.com/NuGet/NuGet.Client/blob/7bff2239195640e51193a8640a153a570e4cabba/src/NuGet.Clients/NuGet.VisualStudio.Common/IDE/VsHierarchyUtility.cs#L46-L117

@nkolev92 nkolev92 added Partner:JPS Priority:2 Issues for the current backlog. labels Nov 4, 2023
@nkolev92
Copy link
Member

nkolev92 commented Nov 9, 2023

@joj
What's the urgency of this? We can discuss priorities offline.

@Barsonax
Copy link

Barsonax commented Dec 5, 2023

Getting this error as well after adding a project reference to a esproj (Microsoft.VisualStudio.JavaScript.Sdk/0.5.127-alpha) from a csproj. Works in Rider and on the commandline just not in visual studio.

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

Successfully merging a pull request may close this issue.

4 participants