3
votes

My project was created via dotnet new webapi --name=ProjectName. I've setup a build definition in VSTS. The Deployment to Azure runs fine, but I can't figure out how to run my migrations, i.e., dotnet ef database update

I've reviewed several of the other Stack Overflow questions. Though helpful, none of them provided a current solution. References:

The closest I've come to being successful is adding tasks like so:

  • Replace Tokens: Update Connection String
  • Command Line: set ASPNETCORE_ENVIRONMENT=Production
  • Command Line: dotnet ef database update -v

This almost works, but for some reason ef still targets development.

Any recent solutions?

1
Can you share the detail log on the OneDrive? (set system.debug variable to true, then queue build and share this log) Try to add variable ASPNETCORE_ENVIRONMENT and specify Production value then try again.starian chen-MSFT
@starianchen-MSFT. Awesome! Adding ASPNETCORE_ENVIRONMENT to my variables worked. I had also looked at this question: stackoverflow.com/questions/44690138/… which led me to believe that your recommendation wouldn't work, but I was pleasantly surprised. Thanks!dapperdan1985
Great! I post an answer that you can accept it as answer. On the other hand, another thread's issue is different, it runs the app on azure but you call dotnet ef command during build/release that the environment is on build/release agent.starian chen-MSFT

1 Answers

2
votes

Adding ASPNETCORE_ENVIRONMENT variable to build/release definition and specify Production value.