Skip to content

TargetInvocationException when running migrations with dotnet cli #856

Description

@giggio

It seems the new dotnet cli extension is having problems loading the dll. I am getting the exception below when I try to run it.

dotnet fm migrate --connection '<connectionstring>' --processor SqlServer2016 --assembly .\bin\Debug\netcoreapp2.0\nh.dll

This is the stack trace:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'FluentNHibernate, Version=2.1.1.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at FluentMigrator.Runner.MigrationRunner.GetMigrationRunnerConventions(IRunnerContext runnerContext) in Z:\buildAgent\work\89282cfb76b17ca5\src\FluentMigrator.Runner\MigrationRunner.cs:line 185
   at FluentMigrator.Runner.MigrationRunner..ctor(IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor, IVersionTableMetaData versionTableMetaData, IMigrationRunnerConventions migrationRunnerConventions) in Z:\buildAgent\work\89282cfb76b17ca5\src\FluentMigrator.Runner\MigrationRunner.cs:line 91
   at FluentMigrator.Runner.Initialization.TaskExecutor.Initialize() in Z:\buildAgent\work\89282cfb76b17ca5\src\FluentMigrator.Runner\Initialization\TaskExecutor.cs:line 85
   at FluentMigrator.Runner.Initialization.TaskExecutor.Execute() in Z:\buildAgent\work\89282cfb76b17ca5\src\FluentMigrator.Runner\Initialization\TaskExecutor.cs:line 90
   at FluentMigrator.DotNet.Cli.Commands.BaseCommand.ExecuteMigrations(MigratorOptions options, IConsole console)
   at FluentMigrator.DotNet.Cli.Commands.Migrate.OnExecute(IConsole console)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments) in C:\projects\commandlineutils\src\CommandLineUtils\Conventions\ExecuteMethodConvention.cs:line 86
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<OnExecute>d__1.MoveNext() in C:\projects\commandlineutils\src\CommandLineUtils\Conventions\ExecuteMethodConvention.cs:line 64
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext() in C:\projects\commandlineutils\src\CommandLineUtils\Conventions\ExecuteMethodConvention.cs:line 25
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass126_0.<OnExecute>b__0() in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.cs:line 505
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute[TApp](CommandLineContext context) in C:\projects\commandlineutils\src\CommandLineUtils\CommandLineApplication.Execute.cs:line 31
   at FluentMigrator.DotNet.Cli.Program.Main(String[] args)

This only happens if the project that contains fm also contains FluentNHibernate. If fm is the only NuGet dependency it runs just fine.

You can see the code here: https://github.com/giggio/exemplonhdnetstandard2/tree/fm-error/nh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions