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

Support VS 2019 Solution Filter feature. Also supports project not in solution, or unloaded projects. Need to restore complete solution (via CLI or VS) first. #5820

Closed
davkean opened this issue Aug 30, 2017 · 13 comments
Labels
Functionality:SDK The NuGet client packages published to nuget.org Style:PackageReference Type:DCR Design Change Request
Milestone

Comments

@davkean
Copy link

davkean commented Aug 30, 2017

From @abpiskunov on August 29, 2017 16:32

I have follwoing solution structure:

ClassLibrary1 (classic net46)
somefolder
ClassLibrary7
\ClassLibrary7 (core net46)

ClassLibrary7 has project reference for ClassLibrary1 in the form that specify Guid:

<ProjectReference Include="..\..\..\ClassLibrary1\ClassLibrary1.csproj"> <Project>{2684d895-d7ce-4b24-a29e-caed2291e2ea}</Project> <Name>ClassLibrary1</Name> </ProjectReference>

Build fails both from VS and from command line saying that

"C:\Users\antonpis\source\repos\ClassLibrary7\ClassLibrary7\ClassLibrary7.csproj" (default target) (1) ->
(ReportAssetsLogMessages target) ->
c:\users\antonpis\source\repos\ClassLibrary7\ClassLibrary7\ClassLibrary7.csproj : error NU1105: Unable to find project information for 'c:\users\antonpis \source\ClassLibrary1\ClassLibrary1.csproj'. The project file may be invalid or missing targets required for restore. [C:\Users\antonpis\source\repos\Class Library7\ClassLibrary7\ClassLibrary7.csproj]

Classic csproj would work in this case (VS however showed a warning but built fine) both in VS and command line (command line did not have warnings)

Copied from original issue: dotnet/project-system#2759

@davkean
Copy link
Author

davkean commented Aug 30, 2017

From @abpiskunov on August 29, 2017 16:40

Note: removing Guid and Name metadata from ProjectReference would fix that, but imagine users converting tehir projects and see errors when where there should be no error at all... they know that csproj file does exist in that location.

@davkean
Copy link
Author

davkean commented Aug 30, 2017

Can you expand on above? Do you mean that ClassLibrary1.csproj is referenced but not included in the solution?

@davkean
Copy link
Author

davkean commented Aug 30, 2017

From @abpiskunov on August 30, 2017 0:28

yes, correct

@davkean
Copy link
Author

davkean commented Aug 30, 2017

This is NuGet not generating an assets file for this project. I have no idea what we should be doing about this situation.

@emgarten
Copy link
Member

emgarten commented Aug 30, 2017

The reason NuGet does not generate an assets file is because when reading the project references from DTE there is a failure when trying to get the project details for the dependency project. If the project system fixed this then NuGet would restore the project.

Overall the error message looks correct here. I don't think that NuGet is the right home for this (if it should be fixed).

@abpiskunov
Copy link

what errors you get from DTE?

@emgarten
Copy link
Member

emgarten commented Aug 30, 2017

Reference.SourceProject is null or throws an exception when accessing it. Which makes sense since the project system doesn't have the project which is outside of the solution, but this means that NuGet can't restore it since we are working within VS and not shelling out to restore any path found.

@abpiskunov
Copy link

hm , but you do have full path to csproj file don't you? it is specified in the ProjectReference. Could you do something with that without DTE?

@emgarten
Copy link
Member

Not that I know of. NuGet currently doesn't have a way to work with msbuild directly from VS, the project system handles this and for classic projects NuGet works by using an interface to read PackageReferences, and IVSHierarchy/DTE to read properties needed for restore.

@emgarten emgarten added the Resolution:External This issue appears to be External to nuget label Aug 30, 2017
@emgarten
Copy link
Member

The project system handles reading project files, which is the missing piece here, I think this issue is best tracked here: dotnet/project-system#2759

@jainaashish
Copy link
Contributor

We met with project system and platform team about this issue, and the current thought is that NuGet can persist unhashed dependency graph of project so that later when the project is unloaded or out of solution, it can still use persisted dependency graph to continue with Restore. So reopening this issue for further tracking.

@jainaashish jainaashish reopened this Nov 8, 2018
@jainaashish jainaashish added Functionality:SDK The NuGet client packages published to nuget.org Type:DCR Design Change Request Style:PackageReference and removed Resolution:External This issue appears to be External to nuget labels Nov 8, 2018
@jainaashish jainaashish added this to the 5.0 milestone Nov 8, 2018
@jainaashish
Copy link
Contributor

Took a stab at it and the initial POC is NuGet/NuGet.Client#2521

@jainaashish jainaashish changed the title Core projects fail to build when they reference other projects not included to solution Restore inside Visual Studio fails for projects when they reference other projects not included in solution Dec 19, 2018
@jainaashish jainaashish self-assigned this Dec 20, 2018
@rrelyea rrelyea added Preview2 and removed Preview2 labels Jan 11, 2019
@rrelyea rrelyea added Preview3 and removed Preview3 labels Jan 30, 2019
@rrelyea rrelyea changed the title Restore inside Visual Studio fails for projects when they reference other projects not included in solution Enable restore in VS to succeed if a project is not loaded, but has previously been restored Feb 13, 2019
@rrelyea rrelyea changed the title Enable restore in VS to succeed if a project is not loaded, but has previously been restored Enable restore in VS to succeed if a project is not part of solution or is not loaded, but has previously been restored Feb 13, 2019
@rrelyea rrelyea changed the title Enable restore in VS to succeed if a project is not part of solution or is not loaded, but has previously been restored Support VS 2019 Solution Filter feature. Also supports project not in solution, or unloaded projects. Need to restore complete solution (via CLI or VS) first. Apr 3, 2019
@thargy
Copy link

thargy commented Nov 21, 2021

I am still getting this problem. In VS2022. If Sln S has project A that includes project B from outside of Sln S (in Sln T). Rebuilding B separately is not enough. I have to also run dotnet restore (via the CLI) on Sln S before project A will build.

So, in my scenario, where Sln S repo includes a submodule of Sln T and then adds a <ProjectReference> in A to B I cannot get it to build automatically on checkout.

However, adding the following:

  <Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="Exists('$(SilkSource)')">
    <!-- Attempt workaround for https://github.com/NuGet/Home/issues/5820 -->
    <Exec Command="dotnet restore" />
  </Target>

At least allows dotnet build to run on clean checkout (though VS 2022 stil fails with the error until you run the CLI build/restore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:SDK The NuGet client packages published to nuget.org Style:PackageReference Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

6 participants