dotNET
dotNET

Reputation: 35400

MSBuild can't use absolute path DLLs?

MSBuild tells me that it cannot locate the reference included in the following task (this is an inline task):

<Task>
  <Reference Include="WindowsBase" />
  <Reference Include="$(SolutionDir)ImageTextWriter\bin\$(Configuration)\ImageTextWriter.dll" />
  ...
</Task>

I have confirmed that this file actually exists at the specified path. Yet MSBuild returns

System.IO.FileNotFoundException: Could not load file or assembly 'ImageTextWriter, Version=...

Am I doing something wrong?

Note: I'm not an MSBuild pro, but this post tells me that hard-coded paths should work.

Upvotes: 1

Views: 623

Answers (2)

weir
weir

Reputation: 4761

I wonder if strong assembly naming is the culprit. Try replacing

<Reference Include="$(SolutionDir)ImageTextWriter\bin\$(Configuration)\ImageTextWriter.dll" />

with

<Reference Include="$(SolutionDir)ImageTextWriter\bin\$(Configuration)\ImageTextWriter.dll">
    <SpecificVersion>False</SpecificVersion>
</Reference>

If that fails, revisit the possibility that the cleaning of ImageTextWriter.dll from bin/ earlier in the build is somehow responsible (even though your examination of the detailed log output earlier seemed to rule that out):

  1. Manually copy ImageTextWriter.dll to some arbitrary folder outside the project altogether.
  2. Temporarily change the Include path to the full, hard-coded path to that copy of the file.
  3. Click your heels three times...

EDIT

I did some testing and found:

  • SpecificVersion metadata is not allowed when the Reference element is in a Task. So much for my first idea above!
  • However, changing <Task> to <Task Evaluate="True"> is required for property expansion in the context where you are using $(SolutionDir) and $(Configuration).

    • Here is the construct with which I verified the behavior:
      
      <PropertyGroup>
          <pathfoo>C:\some\path</pathfoo>
      </PropertyGroup>
      <UsingTask [...]>
          <Task Evaluate="True">
              <Reference Include="$(pathfoo)\some.dll />
              [...]
          </Task>
      </UsingTask>
      
    • And here is the documentation that led me to try it (emphasis mine):

      UsingTaskBodyType Contains the inline task implementation. Content is opaque to MSBuild.

      UsingTaskBodyType_Evaluate ... Whether the body should have properties expanded before use. Defaults to false.

Upvotes: 1

PinBack
PinBack

Reputation: 2564

You could try that one:

<Reference Include="ImageTextWriter">
  <HintPath>$(SolutionDir)ImageTextWriter\bin\$(Configuration)\ImageTextWriter.dll</HintPath>
</Reference>

But if this is the project that creates the ImageTextWriter.dll, I don't suppose that's possible.

Upvotes: 0

Related Questions