none
Frustrating build scenarios

    Question

  • I'm working at a site that has used NuGet a lot for their shared libraries, it's a bit of a mess and I'm seeing scenarios that are new to me even after a decade of .Net development.

    One thing I'm seeing is that we have explicit project references to assemblies/packages that are only indirectly used by a project, e.g. ProjectA binds to Assembly_X which binds to Assembly_Y.

    In this case the project has an explicit ref to Assembly_x and Assembly_Y even though there's no direct code reference in the project to Assembly_Y.

    The reason they do this is so they can set "Copy Local" to true for Assembly_Y (and other assemblies) and thus ensure the build output folder contains every assembly needed at runtime, they can just deploy the folder contents and be sure all runtime assembly references will resolve.

    This is a pain, for example I cant use tools to remove unused references from a project because the build output will no longer contain references to things like Assembly_Y and so will fault at runtime.

    I've never used NuGet heavily and so I'm unsure if NuGet provides runtime, probing services or only build time.

    In the past all indirect assembly references I've worked with have been GAC based so runtime discovery of them has been a non-issue (providing they're installed in the GAC) for example the .Net Framework itself presents no issues.

    Does/should adding a NuGet reference to some package automatically add explicit project references for that packages own dependencies?

    Any info or best practice here is much appreciated!

    Thanks

    Korp.

    Tuesday, January 26, 2016 5:16 PM

Answers

  • Hi Korp,

    >>Does/should adding a NuGet reference to some package automatically add explicit project references for that packages own dependencies?

    Like this site:

    https://www.nuget.org/

    This is the office explanation for it:

    NuGet is the package manager for the Microsoft development platform including .NET. The NuGet client tools provide the ability to produce and consume packages. The NuGet Gallery (nuget.org) is the central package repository used by all package authors and consumers

    My understanding is that it provides many packages/assemblies which could refer to in our projects directly, so we don't have to install them and then add them manually in our project references, as it said that "When you use NuGet to install a package, it copies the library files to your solution and automatically updates your project (add references, change config files, etc.). If you remove a package, NuGet reverses whatever changes it made so that no clutter is left".

    In addition, we could also create a custom NuGet package:

    http://stackoverflow.com/questions/14527615/can-i-publish-a-private-nuget-package

    >>Does/should adding a NuGet reference to some package automatically add explicit project references for that packages own dependencies?

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 28, 2016 5:32 AM
    Moderator