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

PackageReference assemblies not returned by GetReferences() for full framework projects #33

Closed
jmezach opened this issue Feb 4, 2018 · 7 comments

Comments

@jmezach
Copy link
Contributor

jmezach commented Feb 4, 2018

It seems that GetReferences() on ProjectAnalyzer doesn't return assemblies from NuGet packages if PackageReference is being used instead of packages.config. This causes compilation errors in Roslyn workspaces.

Interestingly this only seems to be a problem when the host is .NET Core. It works just fine when the host is .NET Framework. I added some tests in this commit that show this behaviour. I also see errors in the test output which are very similar to #29.

@daveaglick
Copy link
Collaborator

daveaglick commented Feb 14, 2018

I suspect the problem here is that the NuGet targets that know how to handle PackageReference are only included with the .NET Core SDK. It's possible that Visual Studio does some magic to locate those targets even for classic .NET project files. I also see an interesting comment to the docs here:

PackageReference can be used with non-NETCore projects if the project system supports it--so the real answer depends on Unity itself. As for NuGet, it checks if the project supports VSProject4 to determine if it can read/write PackageReferences

This also suggests there's some kind of connection to the VS project system.

Are you able to submit your tests as a PR so I can bring them in? Once we've got the failing tests merged we can take it from there.

@jmezach
Copy link
Contributor Author

jmezach commented Feb 17, 2018

Sure thing. Created #37.

@jmezach
Copy link
Contributor Author

jmezach commented Feb 28, 2018

Looks like this got worse. I'm now completely unable to use this library to load up a full framework solution which has project to project references. Not sure what changed, but I think it has to do with a recent Visual Studio update. Any progress on this issue?

@daveaglick
Copy link
Collaborator

Not with this issue specifically, but I'll be pushing a new release within the hour that addresses the broader problems you described. Recently, every time VS or the .NET Core SDK updates Buildalyzer breaks because the MSBuild APIs that it uses aren't compatible with the newest MSBuild stuff in the SDK.

@daveaglick
Copy link
Collaborator

Been chasing this down and I'm pretty sure at this point that the .NET Core SDK can't build legacy project files that use PackageReference (even though it can build legacy project files). The problem is a missing ResolveNugetPackageAssets target:

2018-06-22_13h40_02

I've verified this by running dotnet build on the command line for the LegacyFrameworkProjectWithPackageReference test, and it fails to restore and reference the PackageReference too.

I'm going to attempt to identify this special case and revert to the framework build tools when it's encountered.

@daveaglick
Copy link
Collaborator

Using the .NET Framework tools from .NET Core did resolve the PackageReference but the problem now is that attempting to use the .NET Framework tools from a .NET Core host results in several task assemblies not being able to be loaded because they're built for .NET Framework.

@daveaglick
Copy link
Collaborator

daveaglick commented Jun 22, 2018

Going to close this as "won't fix" due to a limitation with MSBuild: you simply can't build a legacy project file that uses PackageReference from a .NET Core host. It works under VS because VS can act as a .NET Framework host.

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

2 participants