@ECHO OFF REM ************************************************* REM here are the args for this script REM REM deploy-ef2dot1-migrations.bat migrationsDllName [startupDllName] [dbContextClassName] REM REM Any of the args in [brackets] are optional REM REM ************************************************* if [%1] EQU [] ( ECHO no parameters specified ECHO this isn't going to work ECHO. ECHO here are the args for this script ECHO. ECHO deploy-ef2-migrations.bat migrationsDllName [startupDllName] [dbContextClassName] ECHO. ECHO Any of the args in [brackets] are optional EXIT /B ) set EfMigrationsNamespace=%1 if [%2] EQU [] ( ECHO no additional parameters specified ECHO assuming everything in %1 set EfMigrationsDllDepsJson=%~n1.deps.json set EfMigrationsDllRuntimeConfig=%~n1.runtimeconfig.json set EfMigrationsDllName=%1 set StartupDllName=%1 ) else ( ECHO additional parameters were specified ECHO assuming migrations in one DLL and startup DLL is %2 set EfMigrationsDllDepsJson=%~n2.deps.json set EfMigrationsDllRuntimeConfig=%~n2.runtimeconfig.json set EfMigrationsDllName=%1 set StartupDllName=%2 ) set DllDir=%cd% set PathToNuGetPackages=%USERPROFILE%\.nuget\packages set PathToNuGetPackages_Fallback1="C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback" set PathToNuGetPackages_Fallback2="C:\Program Files\dotnet\sdk\NuGetFallbackFolder" set PathToEfDll="not-found" set PathToEfDll_Option=%cd%\ef.dll if %PathToEfDll% EQU "not-found" ( if exist %PathToEfDll_Option% ( ECHO found ef.dll at %PathToEfDll_Option% set PathToEfDll=%PathToEfDll_Option% ) else ( ECHO ef.dll not found at %PathToEfDll_Option% ) ) set PathToEfDll_Option=%programfiles%\dotnet\sdk\2.1.301\DotnetTools\dotnet-ef\2.1.1\tools\netcoreapp2.1\any\tools\netcoreapp2.0\any\ef.dll if %PathToEfDll% EQU "not-found" ( if exist %PathToEfDll_Option% ( ECHO found ef.dll at %PathToEfDll_Option% set PathToEfDll="%PathToEfDll_Option%" ) else ( ECHO ef.dll not found at %PathToEfDll_Option% ) ) set PathToEfDll_Option=%PathToNuGetPackages_Fallback1%\microsoft.entityframeworkcore.tools.dotnet\2.0.1\tools\netcoreapp2.0\ef.dll if %PathToEfDll% EQU "not-found" ( if exist %PathToEfDll_Option% ( ECHO found ef.dll at %PathToEfDll_Option% set PathToEfDll=%PathToEfDll_Option% ) else ( ECHO ef.dll not found at %PathToEfDll_Option% ) ) set PathToEfDll_Option=%PathToNuGetPackages%\microsoft.entityframeworkcore.tools.dotnet\2.0.0\tools\netcoreapp2.0\ef.dll if %PathToEfDll% EQU "not-found" ( if exist %PathToEfDll_Option% ( ECHO found ef.dll at %PathToEfDll_Option% set PathToEfDll=%PathToEfDll_Option% ) else ( ECHO ef.dll not found at %PathToEfDll_Option% ) ) if %PathToEfDll% EQU "not-found" ( ECHO. ECHO **** ERROR: could not find ef.dll **** ECHO. ECHO OH! SUCH UNRELENTING FAILURE! ECHO But it wasn't like we didn't try. This script actually looked in different 3 places for ef.dll. ECHO Let's face it. It's that ef.dll that we really need to do an ef migration deploy with just the DLLs. ECHO But that ef.dll is tricky to find. ECHO. ECHO Be sure to tell the EF Core team how hard it is to deploy migrations via DLL. ECHO And let them know that it's mostly because it's impossible to find the ef.dll. ECHO It would be so much easier if we could just grab ef.dll during the build and ECHO have it show up as a dependency in our "dotnet publish" output dir. ECHO. ECHO Oh? You want the link to their github project so you can mention it directly ECHO to them in a discussion and tag @benday in that discussion? ECHO That's a great idea! Here ya go. Here's the link to the EF Core project. ECHO https://github.com/aspnet/EntityFrameworkCore ECHO Just remember to be polite. And also remember that @bricelam is a good guy. ECHO. ECHO And on that note, exiting... ECHO. ECHO ps. sorry your ef core migrations didn't deploy. :( EXIT /b 1 ) if [%3] EQU [] ( ECHO no dbcontext name parameter specified ECHO here's hoping that everything works out for you ECHO. ECHO here goes nuthin'... ECHO. dotnet exec --depsfile .\%EfMigrationsDllDepsJson% --additionalprobingpath %PathToNuGetPackages% --additionalprobingpath %PathToNuGetPackages_Fallback1% --additionalprobingpath %PathToNuGetPackages_Fallback2% --runtimeconfig %EfMigrationsDllRuntimeConfig% %PathToEfDll% database update --assembly .\%EfMigrationsDllName% --startup-assembly .\%EfMigrationsDllName% --project-dir . --verbose --root-namespace %EfMigrationsNamespace% ) else ( ECHO dbcontext name parameter was specified ECHO the dbcontext class name I'll be using is %3 ECHO. ECHO here goes nuthin'... ECHO. dotnet exec --depsfile .\%EfMigrationsDllDepsJson% --additionalprobingpath %PathToNuGetPackages% --additionalprobingpath %PathToNuGetPackages_Fallback1% --additionalprobingpath %PathToNuGetPackages_Fallback2% --runtimeconfig %EfMigrationsDllRuntimeConfig% %PathToEfDll% database update --assembly .\%EfMigrationsDllName% --startup-assembly .\%EfMigrationsDllName% --project-dir . --verbose --root-namespace %EfMigrationsNamespace% --context %3 )