Question

I have a project with a bunch of migrations. I can run it manually using the migrator.exe, however am having a hard time getting it to work with NAnt, which I prefer.

I have a *.build file with the following contents:

<project name="Migrations" xmlns="http://nant.sf.net/release/0.85/nant.xsd" default="migrate">
    <loadtasks assembly="../packages/FluentMigrator.1.0.3.0/tools/FluentMigrator.NAnt.dll" />    
    <target name="migrate" description="Migrate the database">
        <property name="version" value="-1" overwrite="false" />
        <migrate
              provider="sqlserver2008"
          connectionstring="data source=*********; Initial Catalog=*****;User Id=*******; Password=********;"
          target="./Migrations/bin/Debug/Migrations.dll"
              directory="Migrations"
          task="migrate"
              to="${version}" />
    </target>
</project>

When this runs I get the following output: BUILD FAILED

C:\projects\ThisProject\Migrations\migrations.build(3,3):
Failure scanning "C:\projects\packages\FluentMigrator.1.0.3.0\tools\FluentMigrator.NAnt.dll" for extensions.
    Could not load file or assembly 'file:///C:\projects\packages\FluentMigrator.1.0.3.0\tools\FluentMigrator.NAnt.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I went looking for depends.exe but that site seems down, any ideas on how to get this working? I'm open to completely new ideas here if I'm doing this all wrong.

======Updated for the complete solution======

The Chairman and armen.shimoon were onto something with their answers.

Step one, I updated my FluentMigrator and FluentMigrator.Tools to 1.0.5.0. The tools were still at 1.0.3.0.

The second step was to update my build file to reference the .NET 4.0 dll. The combination of both fixed the problem, but it didn't show improvement until I referenced the .NET 4.0 dll.

Here is my current .build file for future reference:

<project name="Migrations" xmlns="http://nant.sf.net/release/0.85/nant.xsd" default="migrate">
    <loadtasks assembly="../packages/FluentMigrator.Tools.1.0.5.0/tools/anycpu/40/FluentMigrator.Nant.dll" />
    <target name="migrate" description="Migrate the database">
      <property name="version" value="-1" overwrite="false" />
        <migrate
              database="sqlserver2008"
          connection="data source=******; Initial Catalog=*****;User Id=*****; Password=*****;"
          target="../Migrations/bin/Debug/Migrations.dll"
          verbose="true"
          />
    </target>
</project>
Was it helpful?

Solution

The most likely reason for this is NAnt is running under x86 and your FluentMigrator DLL is running in x64.

Edit: Another possibility is the .NET target framework version. If your NAnt binaries are in .NET 3.5 and FluentMigrator is .NET 4.0, it will fail to load it properly.

OTHER TIPS

My first guess is, that your versions of NAnt and FluentMigrator might have gotten out of sync. So my advice would be to get NAnt 0.92 (as I got to love Chocolatey: Get it via Chocolatey), FluentMigrator 1.0.5.0, and FluentMigrator Tools 1.0.5.0. Perhaps this already fixes your problem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top