dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.75k stars 3.18k forks source link

[Bundles] Bundle generation fails with local repositories with relative path in nuget.config #27022

Open Nefarion opened 2 years ago

Nefarion commented 2 years ago

When running dotnet ef migrations bundle, the process fails for me with an error message:

C:\Program Files\dotnet\sdk\6.0.100\NuGet.targets(130,5): error : The local source '<>\AppData\Local\Temp\v2szyjyq.rk0\lib' doesn't exist. [<>\AppData\Local\Temp\v2szyjyq.rk0\efbundle.csproj]

I managed to interrupt the process so the folder does not get deleted, and looked at the resulting folder.

The issue is, the nuget.config file gets copied from the source project, and my nuget.config file looks like this:

<configuration>
  <packageSources>
    <add key="LibRepo" value=".\lib" />
  </packageSources>
</configuration>

If i replace the relative path with an absolute one, everything works fine.

Maybe it is necessary to do this transformation on the copied nuget.config?

Verbose output

PS <repo>> dotnet ef migrations bundle --context DataContext --project src\Data.Migrations --startup-project src\Server --verbose
Using project '<repo>\src\Data.Migrations\Data.Migrations.csproj'.
Using startup project '<repo>\src\Server\Server.csproj'.
Writing '<repo>\src\Data.Migrations\obj\Data.Migrations.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=<>\AppData\Local\Temp\tmp9A12.tmp /verbosity:quiet /nologo <repo>\src\Data.Migrations\Data.Migrations.csproj
Writing '<repo>\src\Server\obj\Server.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=<>\AppData\Local\Temp\tmp9C26.tmp /verbosity:quiet /nologo <repo>\src\Server\Server.csproj
Build started...
dotnet build <repo>\src\Server\Server.csproj /verbosity:quiet /nologo
[some warnings removed...]
Build succeeded.
    5 Warning(s)
    0 Error(s)

Time Elapsed 00:00:13.82
Build succeeded.
dotnet exec --depsfile <repo>\bin\Server\Server.Debug.deps.json --additionalprobingpath <repo>\packages --additionalprobingpath "C:\Program Files (x86)\ComponentOne\WPF Edition\bin\v5" --additionalprobingpath "C:\Program Files\dotnet\sdk\NuGetFallbackFolder" --runtimeconfig <repo>\bin\Server\Server.Debug.runtimeconfig.json <>\.dotnet\tools\.store\dotnet-ef\6.0.1\dotnet-ef\6.0.1\tools\netcoreapp3.1\any\tools\netcoreapp2.0\any\ef.dll migrations bundle --context DataContext --assembly <repo>\bin\Server\Data.Migrations.Debug.dll --project <repo>\src\Data.Migrations\Data.Migrations.csproj --startup-assembly <repo>\bin\Server\Server.Debug.dll --startup-project <repo>\src\Server\Server.csproj --project-dir <repo>\src\Data.Migrations\ --root-namespace Data.Migrations --language C# --framework net6.0-windows --working-dir <repo> --verbose
Using assembly 'Data.Migrations.Debug'.
Using startup assembly 'Server.Debug'.
Using application base '<repo>\bin\Server'.
Using working directory '<repo>\src\Server'.
Using root namespace 'Data.Migrations'.
Using project directory '<repo>\src\Data.Migrations\'.
Remaining arguments: .
Finding DbContext classes...
Finding IDesignTimeDbContextFactory implementations...
Finding application service provider in assembly 'Server.Debug'...
Finding Microsoft.Extensions.Hosting service provider...
Using environment 'Development'.
Using application service provider from Microsoft.Extensions.Hosting.
Found DbContext 'DataContext'.
Found DbContext 'InMemoryContext'.
Finding DbContext classes in the project...
Using context 'DataContext'.
Building bundle...
dotnet publish --runtime win10-x64 --output <>\AppData\Local\Temp\av5igsjb.j4l\publish --no-self-contained
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
C:\Program Files\dotnet\sdk\6.0.100\NuGet.targets(130,5): error : The local source '<>\AppData\Local\Temp\av5igsjb.j4l\lib' doesn't exist. [<>\AppData\Local\Temp\av5igsjb.j4l\efbundle.csproj]
Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed. Use --verbose to see errors.
   at Microsoft.EntityFrameworkCore.Tools.Commands.MigrationsBundleCommand.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0(String[] args)
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Build failed. Use --verbose to see errors.

Include provider and version information

EF Core version: 6.0.1 (dotnet-ef: 6.0.1 as well) Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: net6.0-windows Operating system: windows 21H2 19044.1348 IDE: -

ajcvickers commented 2 years ago

/cc @bricelam

stavroskasidis commented 2 years ago

Same issue

ajcvickers commented 2 years ago

Notes from triage: To fix this we could either parse and resolve to absolute paths, or if this proves fragile/complex, then try ignoring any failed sources.