Search code examples
c#build.net-assembly

c# assembly references i don't use


How can i get dependency's assembly, that i don't use?

In .sln file i added ProjectDependency B,C in my project A

Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "A", "A\A.csproj", "{BF8FD60F-8519-4DD5-8576-2E6AB68AC640}"
    ProjectSection(ProjectDependencies) = postProject
        {99BEBDF2-B5AE-4900-9BC2-7F0B4A1CDEA1} = {99BEBDF2-B5AE-4900-9BC2-7F0B4A1CDEA1}
        {C8FC5959-A63A-4C0C-B245-BC21FA2027A6} = {C8FC5959-A63A-4C0C-B245-BC21FA2027A6}
    EndProjectSection
EndProject

Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "B", "Dependencies\B\B.csproj", "{C8FC5959-A63A-4C0C-B245-BC21FA2027A6}"
EndProject

Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "C", "Dependencies\C\C.csproj", "{99BEBDF2-B5AE-4900-9BC2-7F0B4A1CDEA1}"
EndProject

But i cant get this dependencies in execution time

I tried write this code in A project

var results1 = AppDomain.CurrentDomain.GetAssemblies();

var results2 = Assembly.GetExecutingAssembly().GetReferencedAssemblies();

to get this B and C dependencies. I didn't find them in results1, results2 variable.

EDIT: I know about way to load assembly by path:

Assembly.Load()

But it doesn't look like flex solution


Solution

  • Just make some fake (empty) class/static property in projects B and C and reference somewhere it in project A. In that way compiler will include your assemblies in build time.