nuke-build / nuke

🏗 The AKEless Build System for C#/.NET
https://nuke.build
MIT License
3.07k stars 367 forks source link

Update to 8.1.0 breaks EntityFrameworkTasks Package/Path #1444

Closed pascal-ws closed 3 weeks ago

pascal-ws commented 3 weeks ago

Usage Information

8.1.0 / 8.0.403 / net8.0 / Windows 11 x64

Description

Hey there,

I have updated my nuke from 8.0.0 to 8.1.0 and now get a error message because it can't find dotnet-ef anymore. See sections below for steps & details.


This worked before I updated my nuke build project.

Is this a new requirement or did something break? I did not have to add this package to the nuke project before the update. I can downgrade nuke to 8.0.0 and then it works again (with nothing else changed).

Other than that it works, when I add the package as instructed it works but I want to ensure that this is now required and not just a workaround for something that maybe broke.

I've noticed in the release for 8.1.0, maybe it's related to that.

Fixed DotCoverTasks and EntityFrameworkTasks tool path resolution

I've also tried updating to the latest version (8.1.2) without success.

Reproduction Steps

In my application I use Entity Framework like:

<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
    <PrivateAssets>all</PrivateAssets>
    <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

I have also installed dotnet-ef as a global tool:

dotnet tool list --global
Paket-ID             Version      Befehle  
-------------------------------------------
dotnet-ef            8.0.10       dotnet-ef
nuke.globaltool      8.1.2        nuke    

In the build I have one target to bundle migrations with EF:

Target BundleMigrations => _ => _
        .DependsOn(StatusPublished)
        .Executes(() =>
        {
            EntityFrameworkTasks.EntityFrameworkMigrationsBundle(s => s
                .SetConfiguration(Configuration)
                .SetOutput(ApiPublish / "Api.Migrate.exe")
                .SetProject(Api)
            );

I upgrade my build project from

<PackageReference Include="Nuke.Common" Version="8.0.0"/>

to

<PackageReference Include="Nuke.Common" Version="8.1.0" />

Expected Behavior

Target is executed sucessfully.

Actual Behavior

Target fails with the following:

11:36:33 [ERR] Target BundleMigrations has thrown an exception
System.Exception: Missing package reference/download.
Run one of the following commands:
  - nuke :add-package dotnet-ef --version 8.0.10
 ---> System.ArgumentException: Could not find package 'dotnet-ef' using:
 - Project assets file 'C:\Code\app\WebApp\App.Build\obj\project.assets.json'
 - NuGet packages config 'C:\Code\app\WebApp\App.Build\App.Build.csproj'
   at Nuke.Common.Assert.NotNull[T](T obj, String message, String argumentExpression) in /_/source/Nuke.Utilities/Assert.cs:line 73
   at Nuke.Common.Tooling.NuGetToolPathResolver.GetPackageDirectory(String[] packageIds, String version) in /_/source/Nuke.Tooling/NuGetToolPathResolver.cs:line 85
   --- End of inner exception stack trace ---
   at Nuke.Common.Assert.Fail(String message, Exception exception) in /_/source/Nuke.Utilities/Assert.cs:line 28
   at Nuke.Common.Tooling.NuGetToolPathResolver.GetPackageDirectory(String[] packageIds, String version) in /_/source/Nuke.Tooling/NuGetToolPathResolver.cs:line 145
   at Nuke.Common.Tooling.NuGetToolPathResolver.GetPackageExecutable(String packageId, String packageExecutable, String version, String framework) in /_/source/Nuke.Tooling/NuGetToolPathResolver.cs:line 29
   at Nuke.Common.Tools.EntityFramework.EntityFrameworkTasks.GetToolPath(String framework) in /_/source/Nuke.Common/Tools/EntityFramework/EntityFrameworkTasks.cs:line 15
   at Nuke.Common.Tools.EntityFramework.EntityFrameworkSettings.GetProcessToolPath() in /_/source/Nuke.Common/Tools/EntityFramework/EntityFrameworkSettings.cs:line 18
   at Nuke.Common.Tools.EntityFramework.EntityFrameworkMigrationsBundleSettings.get_ProcessToolPath() in /_/source/Nuke.Common/Tools/EntityFramework/EntityFramework.Generated.cs:line 1810
   at Nuke.Common.Tooling.ProcessTasks.StartProcess(ToolSettings toolSettings) in /_/source/Nuke.Tooling/ProcessTasks.cs:line 58
   at Nuke.Common.Tools.EntityFramework.EntityFrameworkTasks.EntityFrameworkMigrationsBundle(EntityFrameworkMigrationsBundleSettings toolSettings) in /_/source/Nuke.Common/Tools/EntityFramework/EntityFramework.Generated.cs:line 823
   at Nuke.Common.Tools.EntityFramework.EntityFrameworkTasks.EntityFrameworkMigrationsBundle(Configure`1 configurator) in /_/source/Nuke.Common/Tools/EntityFramework/EntityFramework.Generated.cs:line 853
   at App.Build.Build.<>c.<get_BundleMigrations>b__35_1() in C:\Code\app\WebApp\App.Build\Build.cs:line 294
   at Nuke.Common.Execution.BuildExecutor.<>c.<Execute>b__4_2(Action x) in /_/source/Nuke.Build/Execution/BuildExecutor.cs:line 120
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Nuke.Common.Execution.BuildExecutor.Execute(NukeBuild build, ExecutableTarget target, IReadOnlyCollection`1 previouslyExecutedTargets, Boolean failureMode) in /_/source/Nuke.Build/Execution/BuildExecutor.cs:line 120

Regression?

Yes, it worked in 8.0.0.

Known Workarounds

Add package as instructed.

nuke :add-package dotnet-ef --version 8.0.10

Could you help with a pull-request?

No

matkoch commented 3 weeks ago

That was expected: https://github.com/nuke-build/nuke/issues/1213