#486 – Unnecessary Project References Are Ignored

When we wanted to use the Dog type, which was defined in a DogLibrary assembly, we added a reference to DogLibrary from the project that wanted to use the type.

We then saw that the manifest of DogApplication indicated that DogLibrary was a dependent assembly.

But notice all of the other references that show up in Visual Studio, none of which are seen in the manifest as dependencies.

When you build your project, the build system only created dependencies for referenced projects that your application actually uses.  If we change the code to comment out use of the Dog type, but instead use a Uri type, we’ll get the following manifest:

The manifest now includes a dependency on the System assembly, because that’s where the Uri type is defined.

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

2 Responses to #486 – Unnecessary Project References Are Ignored

  1. Puneet says:

    u mean the compiler while generating the il, removes references like System ?? But why !

    • Sean says:

      Well, if you don’t reference any types within the assembly, there should be no dependency stored in the manifest of the assembly you’re generating. They wouldn’t get used. So the References list in Visual Studio is more like a list of assemblies that you think you might reference. For efficiency reasons, there’s just no reason to include them all as dependencies, if you don’t use them.

Leave a comment