Base solution for your next web application
Open Closed

Migrator.exe error on local machine and on Azure pipeline #9984


User avatar
0
dauren created

- product version: 10.0 - product type: ASP.NET Core & jQuery - framework type .net core - ABP v6

I added a reference to Migrator project in Web.Mvc project. So, I have the migrator.exe and other files in Web.Mvc project folder of artifacts. But I can not run it.

I am having trouble running migrator.exe on my local machine and on release pipeline in azure devops. I am using a Batch script tool in azure devops, where I selected migrator.exe in artifacts. I get the following error:

2021-01-12T08:12:33.9966523Z ##[command]C:\azagent\A1\_work\r2\a\_LinkEd-Classic-CI\drop\LinkEd.Web.Mvc\LinkEd.Migrator.exe 
2021-01-12T08:12:34.0575972Z Cannot use file stream for [C:\azagent\A1\_work\r2\a\_LinkEd-Classic-CI\drop\LinkEd.Web.Mvc\LinkEd.Migrator.deps.json]: No such file or directory
2021-01-12T08:12:34.0578566Z A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.
2021-01-12T08:12:34.0579328Z Failed to run as a self-contained app.
2021-01-12T08:12:34.0580764Z   - The application was run as a self-contained app because 'C:\azagent\A1\_work\r2\a\_LinkEd-Classic-CI\drop\LinkEd.Web.Mvc\LinkEd.Migrator.runtimeconfig.json' was not found.
2021-01-12T08:12:34.0581957Z   - If this should be a framework-dependent app, add the 'C:\azagent\A1\_work\r2\a\_LinkEd-Classic-CI\drop\LinkEd.Web.Mvc\LinkEd.Migrator.runtimeconfig.json' file and specify the appropriate framework.
2021-01-12T08:12:34.2008684Z ##[error]Process completed with exit code -2147450749.

How do I get to generate <b>LinkEd.Migrator.deps.json</b> file?


9 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @dauren

    Could you try to publish your Migrator project and execute it after publishing the project on your Pipeline ?

    You can publish your project as explained here. Then, you can run output executable using dotnet run command.

    Thanks,

  • User Avatar
    0
    dauren created

    Hi, thank you for reply. I have followed your advice and successfully published the migrator project. When I try to run it i receive the following error:

    2021-01-13T17:15:58.4173562Z Unhandled exception. System.IO.FileNotFoundException: Could not find file 'C:\azagent\A1\_work\r2\a\log4net.config'. 2021-01-13T17:15:58.4174850Z File name: 'C:\azagent\A1\_work\r2\a\log4net.config' 2021-01-13T17:15:58.4175321Z at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle) 2021-01-13T17:15:58.4175783Z at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) 2021-01-13T17:15:58.4176369Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) 2021-01-13T17:15:58.4176938Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) 2021-01-13T17:15:58.4177277Z at System.IO.File.OpenRead(String path) 2021-01-13T17:15:58.4177759Z at Abp.Castle.Logging.Log4Net.Log4NetLoggerFactory..ctor(String configFileName) 2021-01-13T17:15:58.4178073Z at lambda_method1(Closure , Object[] ) 2021-01-13T17:15:58.4178491Z at Castle.Core.Internal.ReflectionUtil.Instantiate(ConstructorInfo ctor, Object[] ctorArgs) 2021-01-13T17:15:58.4178996Z at Castle.Core.Internal.ReflectionUtil.Instantiate[TBase](Type subtypeofTBase, Object[] ctorArgs) 2021-01-13T17:15:58.4179522Z at Castle.Core.Internal.ReflectionUtil.CreateInstance[TBase](Type subtypeofTBase, Object[] ctorArgs) 2021-01-13T17:15:58.4180031Z at Castle.Facilities.Logging.LoggingFacility.CreateProperLoggerFactory(LoggerImplementation loggerApi) 2021-01-13T17:15:58.4180534Z at Castle.Facilities.Logging.LoggingFacility.ReadConfigurationAndCreateLoggerFactory() 2021-01-13T17:15:58.4180971Z at Castle.Facilities.Logging.LoggingFacility.Init() 2021-01-13T17:15:58.4181456Z at Castle.MicroKernel.Facilities.AbstractFacility.Castle.MicroKernel.IFacility.Init(IKernel kernel, IConfiguration facilityConfig) 2021-01-13T17:15:58.4181957Z at Castle.MicroKernel.DefaultKernel.AddFacility(IFacility facility) 2021-01-13T17:15:58.4182388Z at Castle.MicroKernel.DefaultKernel.AddFacility[T](Action1 onCreate) 2021-01-13T17:15:58.4182799Z at Castle.Windsor.WindsorContainer.AddFacility[T](Action1 onCreate) 2021-01-13T17:15:58.4183307Z at LinkEd.Migrator.Program.Main(String[] args) in D:\a\1\s\src\LinkEd.Migrator\Program.cs:line 22

    But I see that the log4net.config file is present at the running directory of migrator.exe

  • User Avatar
    0
    dauren created

    OKay, I have figured out how to properly execute the Migrator.exe in pipeline. By default, it looks for the log4net.file in different directory, for some reason. I had to specify the Working directory option for my Batch script step, where you have to specify the directory where the Migrator.exe is located. Working directory option is under Advanced section.

    But now the result is:

    2021-01-13T17:46:27.7228038Z 2021-01-13 20:46:27 | Continue to migration for this host database and all tenants..? (Y/N): 2021-01-13T17:46:27.7229064Z 2021-01-13 20:46:27 | Migration canceled.

    How can I specify that it should migrate all databases (tenant and host) by default?

  • User Avatar
    0
    dauren created

    Okay, so I figured out how to migrate all databases by default, by uncommenting the code which is in Migrator project. But I have another issue now. Whenever I try to run Migrator.exe in deployed folder inetpub/wwwroot it asks for LinkEd.Migrator.deps.json file

  • User Avatar
    0
    musa.demir created

    Hi @dauren

    LinkEd.Migrator.deps.json is also located in publish folder. Can you please check if adding that file to the same folder with application solves the problem.

  • User Avatar
    0
    dauren created

    I tried copying the LinkEd.Migrator.deps.json file and running the Migrator.exe, and it gave error saying that LinkEd.Migrator.runtimeconfig.json was not found, all of these files exist in publish folder and the Migrator.exe runs perfectly ok in publish folder. But I can not update the connection string in appsettings.json of Migrator project during publish, so I can not use Migrator.exe there. Variable substitution changes connection string for appsettings.json in wwwroot folder only. If I manually edit the connection string in appsettings.json of Migrator project in publish folder, migration works perfectly. However, I suppose this is not question of aspnet zero. Thanks for help.

  • User Avatar
    0
    dauren created

    I have migrated the database using Migrator.exe, seems like everything went ok. But, now I cannot enter the application using default credentials. It just redirects me back to login page. What could be the problem?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @dauren

    Is your website HTTP ? If so, You can take a look at this issue.

  • User Avatar
    0
    dauren created

    Thanks, once I enabled SSL it works.