Base solution for your next web application
Open Closed

Build issue on generating migration script #9612


User avatar
0
fncoph created
  • 9.1.0
  • MVC JQuery
  • .net core

Hi,

Currently, I have tried solutions below:

  • https://support.aspnetzero.com/QA/Questions/7800#answer-a8d9bc12-6db8-7b53-1d44-39f3ae5e3f6b
  • https://support.aspnetzero.com/QA/Questions/9553/Error-while-generating-entity-framework-scripts

But same error happens, or any variation of it.

##[error]The process '/usr/bin/dotnet' failed with exit code 1 
Finishing: Generate Migration Scripts

Maybe anyone can also update the documentation, since we only referred here: https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Setting-Up-an-Azure-Pipeline-Mvc-Core

Here's my latest build result: First run:

2020-09-09T11:50:18.8415166Z ##[section]Starting: Generate Migration Scripts
2020-09-09T11:50:18.8423235Z ==============================================================================
2020-09-09T11:50:18.8423818Z Task         : Entity Framework Core Migrations Script Generator
2020-09-09T11:50:18.8424449Z Description  : Tool for projects that use Entity Framework Core Code-First. Generates migration scripts which can be used to update a database (for instance with the task 'Azure SQL Database Deployment').
2020-09-09T11:50:18.8425027Z Version      : 0.0.51
2020-09-09T11:50:18.8425357Z Author       : PEK's Productions
2020-09-09T11:50:18.8425783Z Help         : [More Information](https://github.com/pekspro/EF-Migrations-Script-Generator-Task)
2020-09-09T11:50:18.8426260Z ==============================================================================
2020-09-09T11:50:18.9871623Z Project path: /home/vsts/work/1/s/src/FnCo.ZenTax.EntityFrameworkCore/FnCo.ZenTax.EntityFrameworkCore.csproj
2020-09-09T11:50:18.9873516Z Start-up project path: /home/vsts/work/1/s/src/FnCo.ZenTax.Web.Mvc/FnCo.ZenTax.Web.Mvc.csproj
2020-09-09T11:50:18.9874246Z Target folder: /home/vsts/work/1/a/migrations
2020-09-09T11:50:18.9875144Z Number of database contexts: 1
2020-09-09T11:50:18.9875694Z Checking of dotnet-ef is installed.
2020-09-09T11:50:18.9895694Z [command]/usr/bin/dotnet tool list --global
2020-09-09T11:50:19.1541272Z Package Id      Version      Commands
2020-09-09T11:50:19.1545065Z -------------------------------------
2020-09-09T11:50:19.1646755Z 
2020-09-09T11:50:19.1679241Z Parsing output: "Package Id      Version      Commands
2020-09-09T11:50:19.1680569Z -------------------------------------
2020-09-09T11:50:19.1681230Z "
2020-09-09T11:50:19.1682071Z Installing version undefined of dotnet-ef as global tool.
2020-09-09T11:50:19.1688862Z [command]/usr/bin/dotnet tool install --global dotnet-ef
2020-09-09T11:50:21.5852843Z Specify which project file to use because this '/home/vsts/work/1/s' contains more than one project file.
2020-09-09T11:50:21.5920254Z Usage: dotnet tool install [options] <PACKAGE_ID>
2020-09-09T11:50:21.5920854Z 
2020-09-09T11:50:21.5921326Z Arguments:
2020-09-09T11:50:21.5921861Z   <PACKAGE_ID>   The NuGet Package Id of the tool to install.
2020-09-09T11:50:21.5922126Z 
2020-09-09T11:50:21.5922338Z Options:
2020-09-09T11:50:21.5923120Z   -g, --global              Install the tool for the current user.
2020-09-09T11:50:21.5923861Z   --local                   Install the tool and add to the local tool manifest (default).
2020-09-09T11:50:21.5924730Z   --tool-path <PATH>        The directory where the tool will be installed. The directory will be created if it does not exist.
2020-09-09T11:50:21.5926392Z   --version <VERSION>       The version of the tool package to install.
2020-09-09T11:50:21.5926941Z   --configfile <FILE>       The NuGet configuration file to use.
2020-09-09T11:50:21.5929071Z   --tool-manifest <PATH>    Path to the manifest file.
2020-09-09T11:50:21.5929893Z   --add-source <SOURCE>     Add an additional NuGet package source to use during installation.
2020-09-09T11:50:21.5930941Z   --framework <FRAMEWORK>   The target framework to install the tool for.
2020-09-09T11:50:21.5931652Z   --disable-parallel        Prevent restoring multiple projects in parallel.
2020-09-09T11:50:21.5932327Z   --ignore-failed-sources   Treat package source failures as warnings.
2020-09-09T11:50:21.5932974Z   --no-cache                Do not cache packages and http requests.
2020-09-09T11:50:21.5933790Z   --interactive             Allows the command to stop and wait for user input or action (for example to complete authentication).
2020-09-09T11:50:21.5934500Z   -h, --help                Show command line help.
2020-09-09T11:50:21.5935317Z   -v, --verbosity <LEVEL>   Set the MSBuild verbosity level. Allowed values are q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic].
2020-09-09T11:50:21.6006428Z 
2020-09-09T11:50:21.6124489Z ##[error]The process '/usr/bin/dotnet' failed with exit code 1
2020-09-09T11:50:21.6139150Z ##[section]Finishing: Generate Migration Scripts

1st @ISTeam solution:

  • https://support.aspnetzero.com/QA/Questions/7800#answer-a8d9bc12-6db8-7b53-1d44-39f3ae5e3f6b
2020-09-09T14:35:52.6366500Z ##[section]Starting: Generate Migration Scripts
2020-09-09T14:35:52.6812053Z ==============================================================================
2020-09-09T14:35:52.6813220Z Task         : Entity Framework Core Migrations Script Generator
2020-09-09T14:35:52.6814612Z Description  : Tool for projects that use Entity Framework Core Code-First. Generates migration scripts which can be used to update a database (for instance with the task 'Azure SQL Database Deployment').
2020-09-09T14:35:52.6815556Z Version      : 0.0.51
2020-09-09T14:35:52.6816422Z Author       : PEK's Productions
2020-09-09T14:35:52.6817752Z Help         : [More Information](https://github.com/pekspro/EF-Migrations-Script-Generator-Task)
2020-09-09T14:35:52.6818642Z ==============================================================================
2020-09-09T14:35:53.4389069Z Project path: D:\a\1\s\src\FnCo.ZenTax.EntityFrameworkCore\FnCo.ZenTax.EntityFrameworkCore.csproj
2020-09-09T14:35:53.4390413Z Start-up project path: D:\a\1\s\src\FnCo.ZenTax.Web.Mvc\FnCo.ZenTax.Web.Mvc.csproj
2020-09-09T14:35:53.4391531Z Target folder: D:\a\1\a/migrations
2020-09-09T14:35:53.4392343Z Number of database contexts: 1
2020-09-09T14:35:53.4405587Z Will not try to install dotnet-ef. If you are using .NET Core 3 you could enable 'Install dependencies for .NET Core 3'
2020-09-09T14:35:53.4407424Z to do this automatically. If you are using .NET Core 2 you may need to add the 'Use .NET Core' before running this task.
2020-09-09T14:35:53.4408688Z See here for more details: https://github.com/pekspro/EF-Migrations-Script-Generator-Task
2020-09-09T14:35:53.4409856Z Generating migration script for ZenTaxDbContext in project D:\a\1\s\src\FnCo.ZenTax.EntityFrameworkCore\FnCo.ZenTax.EntityFrameworkCore.csproj
2020-09-09T14:35:53.4475670Z Default build configuration will be used.
2020-09-09T14:35:53.4477894Z The script will be idempotent.
2020-09-09T14:35:53.4498109Z [command]C:\hostedtoolcache\windows\dotnet\dotnet.exe ef migrations script --project D:\a\1\s\src\FnCo.ZenTax.EntityFrameworkCore\FnCo.ZenTax.EntityFrameworkCore.csproj --startup-project D:\a\1\s\src\FnCo.ZenTax.Web.Mvc\FnCo.ZenTax.Web.Mvc.csproj --output D:\a\1\a/migrations/ZenTaxDbContext.sql --context ZenTaxDbContext --verbose --idempotent
2020-09-09T14:35:54.1292764Z 
2020-09-09T14:35:54.1478384Z Welcome to .NET Core 3.1!
2020-09-09T14:35:54.1488330Z ---------------------
2020-09-09T14:35:54.1488767Z SDK Version: 3.1.402
2020-09-09T14:35:54.1488981Z 
2020-09-09T14:35:54.1489165Z Telemetry
2020-09-09T14:35:54.1489376Z ---------
2020-09-09T14:35:54.1490292Z The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
2020-09-09T14:35:54.1491643Z 
2020-09-09T14:35:54.1492390Z Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
2020-09-09T14:35:54.1493212Z 
2020-09-09T14:35:54.1493444Z ----------------
2020-09-09T14:35:54.1493853Z Explore documentation: https://aka.ms/dotnet-docs
2020-09-09T14:35:54.1494381Z Report issues and find source on GitHub: https://github.com/dotnet/core
2020-09-09T14:35:54.1494989Z Find out what's new: https://aka.ms/dotnet-whats-new
2020-09-09T14:35:54.1495448Z Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
2020-09-09T14:35:54.1495962Z Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
2020-09-09T14:35:54.1496421Z Write your first app: https://aka.ms/first-net-core-app
2020-09-09T14:35:54.1496827Z --------------------------------------------------------------------------------------
2020-09-09T14:35:54.3883103Z Specify which project file to use because this 'D:\a\1\s' contains more than one project file.
2020-09-09T14:35:54.4177831Z 
2020-09-09T14:35:54.4340623Z ##[error]The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
2020-09-09T14:35:54.4532215Z ##[section]Finishing: Generate Migration Scripts

2nd result:

2020-09-09T15:33:40.4575951Z ##[section]Starting: Generate Migration Scripts
2020-09-09T15:33:40.4785988Z ==============================================================================
2020-09-09T15:33:40.4787151Z Task         : Entity Framework Core Migrations Script Generator
2020-09-09T15:33:40.4789096Z Description  : Tool for projects that use Entity Framework Core Code-First. Generates migration scripts which can be used to update a database (for instance with the task 'Azure SQL Database Deployment').
2020-09-09T15:33:40.4790225Z Version      : 0.0.51
2020-09-09T15:33:40.4790530Z Author       : PEK's Productions
2020-09-09T15:33:40.4790993Z Help         : [More Information](https://github.com/pekspro/EF-Migrations-Script-Generator-Task)
2020-09-09T15:33:40.4792375Z ==============================================================================
2020-09-09T15:33:40.9164268Z Project path: D:\a\1\s\src\FnCo.ZenTax.EntityFrameworkCore\FnCo.ZenTax.EntityFrameworkCore.csproj
2020-09-09T15:33:40.9165816Z Start-up project path: D:\a\1\s\src\FnCo.ZenTax.Web.Mvc\FnCo.ZenTax.Web.Mvc.csproj
2020-09-09T15:33:40.9166679Z Target folder: D:\a\1\a/migrations
2020-09-09T15:33:40.9167234Z Number of database contexts: 1
2020-09-09T15:33:40.9168072Z Will not try to install dotnet-ef. If you are using .NET Core 3 you could enable 'Install dependencies for .NET Core 3'
2020-09-09T15:33:40.9170850Z to do this automatically. If you are using .NET Core 2 you may need to add the 'Use .NET Core' before running this task.
2020-09-09T15:33:40.9171886Z See here for more details: https://github.com/pekspro/EF-Migrations-Script-Generator-Task
2020-09-09T15:33:40.9173149Z Generating migration script for ZenTaxDbContext in project D:\a\1\s\src\FnCo.ZenTax.EntityFrameworkCore\FnCo.ZenTax.EntityFrameworkCore.csproj
2020-09-09T15:33:40.9251390Z Default build configuration will be used.
2020-09-09T15:33:40.9252351Z The script will be idempotent.
2020-09-09T15:33:40.9277568Z [command]"C:\Program Files\dotnet\dotnet.exe" ef migrations script --project D:\a\1\s\src\FnCo.ZenTax.EntityFrameworkCore\FnCo.ZenTax.EntityFrameworkCore.csproj --startup-project D:\a\1\s\src\FnCo.ZenTax.Web.Mvc\FnCo.ZenTax.Web.Mvc.csproj --output D:\a\1\a/migrations/ZenTaxDbContext.sql --context ZenTaxDbContext --verbose --idempotent
2020-09-09T15:33:41.1219632Z Specify which project file to use because this 'D:\a\1\s' contains more than one project file.
2020-09-09T15:33:41.1290460Z 
2020-09-09T15:33:41.1477284Z ##[error]The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
2020-09-09T15:33:41.1550161Z ##[section]Finishing: Generate Migration Scripts

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

    Hi,

    Is there any detail about this error ?

    ##[error]The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1

    Could you also share your final "Entity Framework Core Migrations Script Generator" task content ?

  • User Avatar
    0
    fncoph created

    Hi,

    This is the last run setting for Migration Script

    I even tried checking the "install dependencies for .net 3.0", but same result. Already tried switching from different agent spec as well.

    Before GMS, I tried to run command below using command prompt: dotnet tool install --global dotnet-ef

    Thank you

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @fncoph

    I think this is a built-in step for Azure CI/CD. Did you try to replace this step with a command step ? Which you can directly execute dotnet ef {params} ?

    By the way, why do you need to generate EF Core migration scripts ? Can't you just apply changed to database using "dotnet ef database update" command ?

  • User Avatar
    0
    fncoph created

    Hi @ismcagdas,

    We're fairly only following the pipeline instructions from this page: https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Setting-Up-an-Azure-Pipeline-Mvc-Core#additional-pipeline-steps-for-the-mvc-project

    Since we're getting this error below, so I tried some other workarounds and see if it works.

    2020-09-09T14:35:54.4340623Z ##[error]The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
    2020-09-09T14:35:54.4532215Z ##[section]Finishing: Generate Migration Scripts
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @fncoph

    Thanks. We will work on this, please follow https://github.com/aspnetzero/aspnet-zero-core/issues/3493

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi All,

    It seems like, two things must be done to solve this problem;

    1. Don't select "Install dependencies for .NET Core 3" for "Generate Migration Scripts" step;

    1. Create a new step before "Generate Migration Scripts" step to instlal dotnet-ef tool.