Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should EntityFrameworkTasks use dotnet-ef.exe rather than dotnet.exe #1213

Open
michael-wolfenden opened this issue Jul 20, 2023 · 2 comments

Comments

@michael-wolfenden
Copy link

michael-wolfenden commented Jul 20, 2023

Usage Information

NUKE Execution Engine version 7.0.2 (Windows,.NETCoreApp,Version=v6.0)

Description

EntityFrameworkTasks expects dotnet-ef to be added as a dotnet tool instead of allowing it to be added as a nuget package reference via nuke :add-package dotnet-ef

Reproduction Steps

Given the following task:

Target EF => _ => _
    .Executes(() =>
    {
        EntityFrameworkTasks.EntityFrameworkDatabaseDrop());
    });

Running nuke EF throws the following exception

09:27:02 [INF] > "C:\Program Files\dotnet\dotnet.exe" ef database drop
09:27:03 [ERR] Could not execute because the specified command or file was not found.
09:27:03 [ERR] Possible reasons for this include:
09:27:03 [ERR]   * You misspelled a built-in dotnet command.
09:27:03 [ERR]   * You intended to execute a .NET program, but dotnet-ef does not exist.
09:27:03 [ERR]   * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

This is expected as I haven't added dotnet-ef to the project.

So I now run

nuke :add-package dotnet-ef

But running nuke EF throws the same exception

Expected Behavior

I would expect that all that was required to use EntityFrameworkTasks would be to install the dotnet-ef nuget package via nuke :add-package dotnet-ef

Actual Behavior

The actual behaviour is that you are required to install dotnet-ef as a dotnet tool via

dotnet new tool-manifest
dotnet tool install dotnet-ef

Regression?

No response

Known Workarounds

The issue stems from the tool using dotnet.exe as the tool executable rather than dotnet-ef.exe.

We could resolve dotnet-ef using

var dotnetEF = NuGetToolPathResolver.GetPackageExecutable(
    packageId: "dotnet-ef",
    packageExecutable: "dotnet-ef.exe");

But we would then have to change the tasks to not prefix the commands with ef. For example ef database drop would need to change to database drop

Could you help with a pull-request?

Yes

@matkoch
Copy link
Member

matkoch commented Jul 25, 2023

Feel free to send a PR.

@michael-wolfenden
Copy link
Author

@matkoch This would be a breaking change to anyone who had not installed dotnet-ef as a nuget package via nuke :add-package dotnet-ef. Are you still happy for the change to go ahead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants