LinuxDoku / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

MSBuild Runner Doesn't work with Directory Option #67

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a directory with migrations
2. Set the Directory option in an MSBuild script to point to that directory
3. Run the MSBuild target

What is the expected output? What do you see instead?
The runner should compile the scripts and execute them. It is throwing a 
FileNotFound exception:

 System.IO.FileNotFoundException: Could not load file or assembly 
'Migrator.Framework, Version=0.8.0.29413, Culture=neutral, 
PublicKeyToken=null' or one of its dependencies. The system cannot find the 
file specified.
 File name: 'Migrator.Framework, Version=0.8.0.29413, Culture=neutral, 
PublicKeyToken=null'
    at System.Reflection.Assembly._GetExportedTypes()
    at System.Reflection.Assembly.GetExportedTypes()
    at Migrator.MigrationLoader.GetMigrationTypes(Assembly asm) in 
c:\work\other_projects\migratordotnet\migratordotnet-
trunk\src\Migrator\MigrationLoader.cs:line 88
    at Migrator.MigrationLoader.AddMigrations(Assembly migrationAssembly) 
in c:\work\other_projects\migratordotnet\migratordotnet-
trunk\src\Migrator\MigrationLoader.cs:line 35
    at Migrator.MigrationLoader..ctor(ITransformationProvider provider, 
Assembly migrationAssembly, Boolean trace) in 
c:\work\other_projects\migratordotnet\migratordotnet-
trunk\src\Migrator\MigrationLoader.cs:line 20
    at Migrator.Migrator..ctor(ITransformationProvider provider, Assembly 
migrationAssembly, Boolean trace, ILogger logger) in 
c:\work\other_projects\migratordotnet\migratordotnet-
trunk\src\Migrator\Migrator.cs:line 66
    at Migrator.Migrator..ctor(String provider, String connectionString, 
Assembly migrationAssembly, Boolean trace, ILogger logger) in 
c:\work\other_projects\migratordotnet\migratordotnet-
trunk\src\Migrator\Migrator.cs:line 51
    at Migrator.MSBuild.Migrate.Execute(Assembly asm) in 
c:\work\other_projects\migratordotnet\migratordotnet-
trunk\src\Migrator.MSBuild\MigrateTask.cs:line 161
    at Migrator.MSBuild.Migrate.Execute() in 
c:\work\other_projects\migratordotnet\migratordotnet-
trunk\src\Migrator.MSBuild\MigrateTask.cs:line 144
    at 
Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy 
engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask 
task, Boolean& taskResult)

Original issue reported on code.google.com by geoffl...@gmail.com on 5 Sep 2008 at 10:46

GoogleCodeExporter commented 8 years ago
This does work from NAnt.

Original comment by geoffl...@gmail.com on 5 Sep 2008 at 10:46

GoogleCodeExporter commented 8 years ago
This could be caused by a version conflict. if the migrations where built 
against Migrator.Framework version 0.8.0.2941 but the msbuild task was built 
against a later 
version...

Original comment by michael.aird@gmail.com on 1 Oct 2008 at 8:25

GoogleCodeExporter commented 8 years ago
I'm having the same issue here and there isn't a version conflict. For some 
reason 
it's looking in C:/Windows/Microsoft.NET/Framework/v3.5/ for the 
Migrator.Framework.dll

Building with tools version "2.0".
Target "Migrate: (TargetId:0)" in file "D:\TestProgram\build.proj" from 
project "D:\TestProgram\build.proj":
Using "Message" task from assembly "Microsoft.Build.Tasks, Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Message" (TaskId:0)
  Migrating (TaskId:0)
Done executing task "Message". (TaskId:0)
Using "CreateProperty" task from assembly "Microsoft.Build.Tasks, 
Version=2.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "CreateProperty" (TaskId:1)
Done executing task "CreateProperty". (TaskId:1)
Using "Migrate" task from assembly "D:\TestProgram\lib\Migrator.MSBuild.dll".
Task "Migrate" (TaskId:2)
Compiling:
Domain\AddTestTable.cs
D:\TestProgram\build.proj(15,5): error MSB4018: The "Migrate" task failed 
unexpectedly.
D:\TestProgram\build.proj(15,5): error MSB4018: 
System.IO.FileNotFoundException: 
Could not load file or assembly 'Migrator.Framework, Version=0.7.0.21797, 
Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system 
cannot 
find the file specified.
D:\TestProgram\build.proj(15,5): error MSB4018: File name: 'Migrator.Framework, 
Version=0.7.0.21797, Culture=neutral, PublicKeyToken=null'
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
System.Reflection.Assembly._GetExportedTypes()
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
System.Reflection.Assembly.GetExportedTypes()
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
Migrator.MigrationLoader.GetMigrationTypes(Assembly asm)
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
Migrator.MigrationLoader.AddMigrations(Assembly migrationAssembly)
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
Migrator.MigrationLoader..ctor
(ITransformationProvider provider, Assembly migrationAssembly, Boolean trace)
D:\TestProgram\build.proj(15,5): error MSB4018:    at Migrator.Migrator..ctor
(ITransformationProvider provider, Assembly migrationAssembly, Boolean trace, 
ILogger logger)
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
Migrator.Migrator..ctor(String 
provider, String connectionString, Assembly migrationAssembly, Boolean trace, 
ILogger logger)
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
Migrator.MSBuild.Migrate.Execute(Assembly asm)
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
Migrator.MSBuild.Migrate.Execute()
D:\TestProgram\build.proj(15,5): error MSB4018:    at 
Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy 
engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, 
Boolean& taskResult)
D:\TestProgram\build.proj(15,5): error MSB4018: 
D:\TestProgram\build.proj(15,5): error MSB4018: Assembly manager loaded from:  
C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
D:\TestProgram\build.proj(15,5): error MSB4018: Running under executable  
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe
D:\TestProgram\build.proj(15,5): error MSB4018: --- A detailed error log 
follows. 
D:\TestProgram\build.proj(15,5): error MSB4018: 
D:\TestProgram\build.proj(15,5): error MSB4018: === Pre-bind state information 
===
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: User = ARIAMEDIA\jseekamp
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: DisplayName = 
Migrator.Framework, Version=0.7.0.21797, Culture=neutral, PublicKeyToken=null
D:\TestProgram\build.proj(15,5): error MSB4018:  (Fully-specified)
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Appbase = 
file:///C:/Windows/Microsoft.NET/Framework/v3.5/
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Initial PrivatePath = NULL
D:\TestProgram\build.proj(15,5): error MSB4018: Calling assembly : (Unknown).
D:\TestProgram\build.proj(15,5): error MSB4018: ===
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: This bind starts in 
default 
load context.
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Using application 
configuration 
file: C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe.Config
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Using machine 
configuration 
file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Policy not being applied 
to 
reference at this time (private, custom, partial, or location-based assembly 
bind).
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Attempting download of new 
URL 
file:///C:/Windows/Microsoft.NET/Framework/v3.5/Migrator.Framework.DLL.
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Attempting download of new 
URL 
file:///C:/Windows/Microsoft.NET/Framework/v3.5/Migrator.Framework/Migrator.Fram
ework
.DLL.
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Attempting download of new 
URL 
file:///C:/Windows/Microsoft.NET/Framework/v3.5/Migrator.Framework.EXE.
D:\TestProgram\build.proj(15,5): error MSB4018: LOG: Attempting download of new 
URL 
file:///C:/Windows/Microsoft.NET/Framework/v3.5/Migrator.Framework/Migrator.Fram
ework
.EXE.
D:\TestProgram\build.proj(15,5): error MSB4018: 
Done executing task "Migrate" -- FAILED. (TaskId:2)
Done building target "Migrate" in project "build.proj" -- FAILED.: (TargetId:0)
Done Building Project "D:\TestProgram\build.proj" (migrate target(s)) -- FAILED.

Original comment by jeremyse...@gmail.com on 18 Dec 2008 at 12:17

GoogleCodeExporter commented 8 years ago
Moving to Milestone 9

Original comment by geoffl...@gmail.com on 14 Feb 2009 at 10:47

GoogleCodeExporter commented 8 years ago
The problem appears to be that the working directory is not set to the lib 
folder 
where the MyMigrations.dll is put. To get it working until it's fixed try the 
following:

1. Add a task to copy your migration dll to the Migrator lib folder

2. Use the following task to do the migration (replace <MigratorLibFolder>, 
<ConnectString> and <MyMigrations.dll> with your setup

  <Target Name="Migrate" DependsOnTargets="Build">
    <CreateProperty Value="-1"  Condition="'$(MigrationVersion)'==''">
      <Output TaskParameter="Value" PropertyName="MigrationVersion" />
    </CreateProperty>
    <Exec WorkingDirectory="$(MSBuildProjectDirectory)\<MigratorLibFolder>"
      Command="Migrator.Console.exe SqlServer "<ConnectString>" 
<MyMigrations.dll> -version $(MigrationVersion)" />
  </Target>

This setup works well in my environment.

Thanks for the great library.  This + ASP.NET MVC is bringing us closer to 
Rails for 
the corporation every day!

Original comment by garth.wi...@gmail.com on 17 Feb 2009 at 3:08