I am unable trying to run any EF tools CLI commands after updating Visual Studio and .NET Core versions, receiving the following error each time:
The specified task executable "dotnet" could not be run. System.ComponentModel.Win32Exception (193): The specified executable is not a valid application for this OS platform. [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
This is after updating .NET Core Tools and using Version 3.1
I am able to compile and publish projects targeting 3.0 and 3.1 in both development and production without issue, it only seems that EF builds have issue.
Everything is fine using EF 3.0 and .NET Core 3.0, however as soon as Visual Studio and tools are updated no EF Tools commands function, despite working on 3.0 with the exact same code.
Initially I thought perhaps a corrupt SDK install, however after multiple machine restores, SDK repairs and complete uninstall/reinstall of affected tools it persists.
What steps can we follow to reproduce the issue?
Have existing .NET Core 3.0 project with EF Core 3.0
Install Visual Studio 2019 Update 16.4.2
Update EF Core Tools
Attempt to run any EF Tools command e.g. dotnet ef migrations add test
PM> dotnet ef migrations add test -v
Using project 'C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj'.
Using startup project 'C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj'.
Writing 'C:\_Development\Projects\CoreTaskEngine\obj\TaskEngine.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\ME\AppData\Local\Temp\tmpF435.tmp /verbosity:quiet /nologo C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj
Writing 'C:\_Development\Projects\CoreTaskEngine\obj\TaskEngine.csproj.EntityFrameworkCore.targets'...
dotnet msbuild /target:GetEFProjectMetadata /property:EFProjectMetadataFile=C:\Users\ME\AppData\Local\Temp\tmpFA12.tmp /verbosity:quiet /nologo C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj
Build started...
dotnet build C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj /verbosity:quiet /nologo
wwwroot/js/core/datatables/datatables.js was not found
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: The specified task executable "dotnet" could not be run. System.ComponentModel.Win32Exception (193): The specified executable is not a valid application for this OS platform. [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at System.Diagnostics.Process.Start() [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
Build FAILED.
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: The specified task executable "dotnet" could not be run. System.ComponentModel.Win32Exception (193): The specified executable is not a valid application for this OS platform. [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at System.Diagnostics.Process.Start() [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at Microsoft.AspNetCore.Razor.Tasks.DotNetToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(99,5): error MSB6003: at Microsoft.Build.Utilities.ToolTask.Execute() [C:\_Development\Projects\CoreTaskEngine\TaskEngine.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:04.01
Microsoft.EntityFrameworkCore.Tools.CommandException: Build failed.
at Microsoft.EntityFrameworkCore.Tools.Project.Build()
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Build failed.
EF Core version: 3.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .Net Core 3.1
Operating system: Windows Server 2016
IDE: Visual Studio 2019 16.4.2
@Stephen-Gibson Have you installed as a global tool? This is new for EF Core 3.
@ajcvickers Hi, yes I've got tools installed:
PM> dotnet tool list -g
Package Id Version Commands
--------------------------------------
dotnet-ef 3.1.0 dotnet-ef
PM>
I've been using the global tools successfuly with 3.0 EF Tools on projects using the 3.0 SDK
I'm experiencing the same issue. As a workout, I'm using ef tools 3.0.0 and I'm able to run my project.
@Stephen-Gibson @axelmaldonado We think this may due to using a 32-bit installation on a 64-bit system. Can you do a where donet on the command line to see where it is being pulled from?
Also, try installing the 64-bit SDK if you haven't already done so.
@ajcvickers it looks like this was indeed the problem - somehow a 0kb dotnet file (with no extenstion???) was located at C:\Windows\System32\dotnet, and the EF Tools was trying to build using this file. Possibly an issue with the visual studio update process?
I deleted this file and tried to run the build again, and it worked correctly. Thanks for your help!
@axelmaldonado might be worth checking to see if this solution works for yourself.
Interestingly enough, this only took effect after the update to 3.1 - I checked and the file was still present in backup from the previous version, however it seemed that EF Build Tools ignored it in 3.0.
Most helpful comment
@ajcvickers it looks like this was indeed the problem - somehow a 0kb dotnet file (with no extenstion???) was located at
C:\Windows\System32\dotnet, and the EF Tools was trying to build using this file. Possibly an issue with the visual studio update process?I deleted this file and tried to run the build again, and it worked correctly. Thanks for your help!
@axelmaldonado might be worth checking to see if this solution works for yourself.