本文介绍了EF核心代码优先部署-VSTS管道-hospolicy.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net核心开发项目,首先是Entity Framework代码,正在尝试将EF迁移作为发布步骤运行,建议我使用migration.exe,但据我所知,EF asp.net核心不会生成migration.exe文件.

I'm developing a project using asp.net core, Entity framework code first, am trying to run EF migrations as a release step, i was advised to use migrate.exe, yet as far as i knew ef asp.net core doesn't generate migrate.exe file.

当前在发布步骤中使用以下命令.将ef核心项目的bin文件夹添加到生成的工件后.

Am currently using the below command in the release step. After adding the ef core project's bin folder to the generated artifacts.

命令:

dotnet exec 
--runtimeconfig ./HOST.runtimeconfig.json 
--depsfile ./HOST.deps.json Microsoft.EntityFrameworkCore.Design.dll
--assembly ./DB_CONTEXT_DLL.dll 
--startup-assembly ./HOST.dll --data-dir ./ 
--root-namespace DB_CONTEXT_NAMESPACE 
--verbose database update --context DB_CONTEXT_CLASS -e development 

命令步骤失败,并显示以下错误:遇到致命错误.在'd:\ a \ r1 \ a {Publish articats文件夹} \ drop \ EF \ bin \ release \ netcoreapp1.1 \'中找不到执行该应用程序所需的库'hostpolicy.dll'.

The command step fails with the error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'd:\a\r1\a{Publish articats folder}\drop\EF\bin\release\netcoreapp1.1\'.

我不确定hostpolicy.dll是什么以及如何生成它,因为它没有在EF核心项目的bin文件夹中生成

Am not sure what is the hostpolicy.dll and how to generate it as it isn't generated in the bin folder for the EF core project

有什么建议吗?

推荐答案

您可以在部署过程中进行实体框架迁移.简单步骤:

You can do Entity framework migration during the deploy process. Simple steps:

  1. 创建一个发布配置文件(例如,Web Deploy程序包,右键单击project => Publish)
  2. 通过带有/p:DeployOnBuild=true /p:PublishProfile=[profilename];DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebAppCoreEF.zip"参数
  3. Visual Studio Build任务常规部署程序包
  4. 添加部署任务(例如Azure App Service Deploy)以部署此程序包(可以在发行版中完成)
  1. Create a publish profile (e.g. Web Deploy package, right click project=>Publish)
  2. General deploy package through Visual Studio Build task with /p:DeployOnBuild=true /p:PublishProfile=[profilename];DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebAppCoreEF.zip" arguments
  3. Add deploy task (e.g. Azure App Service Deploy) to deploy this package (You can do it in release)

这篇关于EF核心代码优先部署-VSTS管道-hospolicy.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 10:44