-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
dotnet ef migrations fail when using custom output paths and separate project/startup-projects
Hi folks,
I'm trying to get my projects setup in docker and I'm running into this error:
error MSB4057: The target "GetEFProjectMetadata" does not exist in the project.
I used Brice's suggestion here #23691 (comment) and it works but only when everything is in a single project.
Other issues that are similar but I'm either missing a step or this is broken.
#23691
#12220
Example repo
I have a repo with 4 scenarios here: https://github.com/chris-garrett/EfTools. I removed docker for the time being since this is reproducible without it.
- d180df5 Everything in one project with no modifications to output paths: Works
- 7f0c9b3 Everything in one project with modifications to output paths ([obj|bin]/containers): Works
- 1fb088e Separate projects for contexts / migration tool with no modifications to output paths: Works
- 5c264bc Separate projects for contexts / migration tool with modifications to output paths ([obj|bin]/containers): Does not work
Steps
# nuke any bin/obj folders
$ ./tools-nuke.sh
# create the migration
$ ./tool-create-migration.sh InitialMigration
# run the migration and verify its working
$ ./tool-migrate.sh
Verbose output
$ ./tool-create-migration.sh InitialMigration
Using project './EfTools.Data.csproj'.
Using startup project '../EfTools.Migrations/EfTools.Migrations.csproj'.
Writing 'obj/container/EfTools.Data.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpm1K4cl.tmp /verbosity:quiet /nologo ./EfTools.Data.csproj
Writing 'obj/container/EfTools.Migrations.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=/tmp/tmpKnaJFl.tmp /verbosity:quiet /nologo ../EfTools.Migrations/EfTools.Migrations.csproj
/mnt/nvme0/projects/dotnet/eftools/EfTools.Migrations/EfTools.Migrations.csproj : error MSB4057: The target "GetEFProjectMetadata" does not exist in the project.
Microsoft.EntityFrameworkCore.Tools.CommandException: Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
at Microsoft.EntityFrameworkCore.Tools.Project.FromFile(String file, String buildExtensionsDir, String framework, String configuration, String runtime)
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute(String[] _)
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)
Unable to retrieve project metadata. Ensure it's an SDK-style project. If you're using a custom BaseIntermediateOutputPath or MSBuildProjectExtensionsPath values, Use the --msbuildprojectextensionspath option.
Provider and version information
EF Core version: 5.0.1
Database provider: Microsoft.EntityFrameworkCore.Sqlite
Target framework: .NET 5.0.101
Operating system: Ubuntu 20.04.1 LTS
IDE: command line
corstian, AndrewSilver, georg-jung, autoit4you, AgentEnder and 26 morerick-palmsens, etkr, gabynevada, rannien, Maverik and 1 more