I have been working on my first .NET Core console program and am working to make it operate through multiple PowerShell scripts. When manually executing my FileRelocation program from PowerShell, I go to the appropriate directory and enter the following into the terminal:
dotnet .\FileRelocation.dll [commands for .dll]
This executes without any issue. However, when trying this from a .ps1 file, I am always given the following error:
dotnet : No executable found matching command "dotnet-.\FileRelocation.dll"
At \\chimera\home\freerey\My Documents\C# Projects\File Relocation Program\0.5.1 Beta\scripts\pstest.ps1:2 char:1
+ dotnet .\FileRelocation.dll -v -e C:\Users\freerey\Desktop\firelloc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (No executable f...Relocation.dll":String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
Since initially running into this issue, I have tried writing dotnet ef in the front, only to be told Microsoft.EntityFrameworkCore.Tools.CommandException: No project was found. I have tried running the .csproj file for my program instead of the .dll, but this results in the same outcome.
I feel like I'm missing out on something very obvious here, but due to my lack of experience with PowerShell and the fact that nobody I work with uses it, I still haven't found out why the program fails to run from a script when manually entering this data in works perfectly. The program works completely as intended and I know there isn't any issue with it; I just need to figure out how to get these scripts to stop having errors.
And for anyone curious: I'm running .NET Core 2.1.507, with these runtimes installed:
- Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
- Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
- Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Thanks in advance!

dotnetand.\File_Relocation.dllis really a space character - it looks like PowerShell thinks the command you want it to execute is calleddotnet-.\FileRelocation.dllrather thandotnetwith a parameter.\File_Relocation.dllso the "space" might be some weird unicode character that looks like a space but PowerShell thinks is part of the executable's filename. Try deleting and re-keyingdotnet .\File_Relocation.dllagain in the script file to make sure...dotnetrather than powershell - see similar errors in stackoverflow.com/questions/40941717/… and stackoverflow.com/questions/51181148/… - as a test, try using the full path toFile_Relocation.dllinstead of the relative path.\File_Relocation.dll.