1

I'm creating bild-file for a project containing several 3rd-party libraries located inside a lib-folder. So my build-script looks like this:

<csc target="library" ....>
    <sources>
        <include name="**/*.cs" />
        <!-- common assembly-level attributes -->
        <include name="../../src/CommonAssemblyInfo.cs" />
        <exclude name="Properties/AssemblyInfo.cs" />
    </sources>
    <references>
        <include name="${build.dir}/bin/lib/Should.Fluent.dll" />
    </references>
</csc>

The compilation runs fine, however, runtime doesn't work, saying it can't find the library Should.Fluent.dll. How can I make the program find it?

Alxandr
  • 12,345
  • 10
  • 59
  • 95

1 Answers1

0

The library has to be present either in GAC or in the same directory that the referencing assembly is in. You can copy it manually to check if this fixes the problem - if yes, then add a <copy> task that makes sure you references are present in your output problem.

skolima
  • 31,963
  • 27
  • 115
  • 151
  • You telling me it's not possible to run dlls from another directory than your app or the GAC? Cause I've read about a /lib-switch to csc.exe that tells the program where to search for dlls. – Alxandr Jun 21 '11 at 07:56
  • This switch only works during the compilation, it does nothing during runtime. However, MSBuild automatically copies your references to the output directory, so most developers don't notice this. You can hook into [`AppDomain.CurrentDomain.AssemblyResolve`](http://stackoverflow.com/questions/5260404/resolve-assembly-references-from-another-folder) to change this, but I wouldn't recommend it. – skolima Jun 21 '11 at 08:05
  • I see. Well, guess I'll just have to leave the resources in the same dir then. – Alxandr Jun 21 '11 at 08:08