dotnet exec needs a managed .dll or .exe extension while adding Entity Framework Core (1.1.0) Migrations

2k Views Asked by At

Error Message:

PM> Add-Migration InitialDatabase
dotnet exec needs a managed .dll or .exe extension. The application specified was 'C:\Users\xxxxxx\documents\visual studio 2017\Projects\TheWorld\src\TheWorld\bin\Debug\netcoreapp1.0\TheWorld.runtimeconfig.json'
Process finished with non-zero exit code
PM> 

Visual Studio Version: 2017 RC

Project Dependencies :

Project Dependencies

Error Screenshot : Error Screenshot

5

There are 5 best solutions below

2
On BEST ANSWER

I had the same problem. The only thing I had to do is changing the Target Framework in the Project properties.

Changing the framework version

I hope this helps.

2
On

Tooling for VS and dotnet are still in preview. Try run dotnet ef migrations add InitialDatabase from command line in TheWorld/src folder.

0
On

My context was deploying to AWS Lambda.

The fix was to change the output type to Class Library in the EF project (EFCore) that my lambda was using.

p.s. you might need to change it back when you run migrations etc.

enter image description here

0
On

In VS2017RC - All I had to do was install .NetCore again using Package Manager Console:

Install-Package Microsoft.NETCore.App

Later migration script worked and "dotnet exec needs a managed .dll or .exe extension." error went away.

0
On

I had a similar issue deploying a docker container to AWS Lambda.

I was using a custom container and not the public.ecr.aws/lambda/dotnet:latest.

Because of this, thelambda-entrypoint.sh was getting confused about which deps.json to use and was trying to run dotnet exec on a random json file.

What ended up solving it was setting the environment variable LAMBDA_DOTNET_MAIN_ASSEMBLY to the main assembly name - not including .dll

This name should match the name of your .csproj file. For instance, if your program is myDotnetExample.csproj you would set the environment variable as:

LAMBDA_DOTNET_MAIN_ASSEMBLY = "myDotnetExample"

Once this variable was set, lambda-entrypoint.sh was able to find the proper file and run the program.