Closed gfody closed 3 months ago
PackageReference
only needs the 'top level' packages, or packages where you want a newer version than the min dependency.
If you expand the Dependencies section under Packages you will find the tree of transitive packages all pulled in.
A couple of nits with your example:
Microsoft.Net.Compilers
is legacy and the replacement Microsoft.Net.Compilers.Toolset
is automatically added by the SDK.
If you want a newer version than it pulls in by default then set the property with something like
<MicrosoftNetCompilersToolset_Version>4.10.0</MicrosoftNetCompilersToolset_Version>
Use TargetFramework
instead of TargetFrameworks
- you might get some odd stuff happening due to multitargetting otherwise.
Don't set the OutputType
or OutputPath
properties - the SDK deals with that.
ty I made the suggested edits and "remove unused references" is still listing everything.. maybe this is just an untested scenario, feel free to close this if it's totally unrelated to the sdk. the feature does correctly detect unused references for other noncore console projects.
@gfody I would expect it to remove quite a few of those - e.g. Microsoft.Owin as it is transitive from most of the others. I certainly don't do it that way when migrating one of my projects. I create a new empty systemweb project, and then copy in the files from the original, and just add the leaf packages as required until it runs. Is there perhaps a project reference in your project to another class library project which has all the same packages? This would mean that all the packages were included transitively and so you wouldn't need any of them,
One thing I found was that 'migrating' didn't change the project type guids in the solution file, and this causes some issues of it's own. Unfortunately the built in tooling is not really designed to cover this scenario, and, especially as you should only have 1 head project, it is probably better to do it manually anyway.
I will close this for now, but if you find the actual reason for it doing this, please comment as it will help others.
when I try to remove unused references on my freshly migrated monster w/100's of package refs, it detects all of them as being unused. while migrating I just copied my package refs into the csproj, here's an excerpt below, I wonder if I'm doing it wrong?
thank you for this project btw!