I have written a C# program, published it using visual studio to a folder on my computer(windows), and FTPed those files onto a remote dev server(linux), where they run fine. The program runs manually without issue, but it will not run from the cronjob I have set up. The strange part is what I see in the cron errors output:
Unhandled exception. System.Exception: Required Environment Variable ASPNETCORE_ENVIRONMENT is missing or was not specified
at MyProgram.Startup.LoadConfiguration() in C:\Users\Developer\source\repos\LargerProject\MyProgram\Startup.cs:line 31
at MyProgram.Startup.ConfigureServices() in C:\Users\Developer\source\repos\LargerProject\MyProgram\Startup.cs:line 45
at MyProgram.Program.Main(String[] args) in C:\Users\Developer\source\repos\LargerProject\MyProgram\Program.cs:line 13
/opt/dotNetCore/MyProgram/ExecutionScript.sh: line 3: 1418 Aborted
the body of the execution script:
#!/bin/bash
FILEPATH=/opt/dotNetCore/ProgramData/Program_data.csv
dotnet /opt/dotNetCore/Program/Program.dll $FILEPATH
cronjob:
0,29 * * * * /opt/dotNetCore/Program/ExecutionScript.sh 2> /tmp/ScriptLog.txt 2>&1
ASPNETCORE_ENVIRONMENT is set up as a variable on the dev box, and is picked up when the ExecutionScript is run manually.
As you can see there are references to the development machine(C:\Users\Dev...) that the dev box is finding somehow. I would have thought these would be removed by publishing the program. Do I need to publish to the remote machine to avoid this, or is it likely this is some error in my publishing settings?
I have assumed this is an issue with the publishing of the app but if you have other ideas I'd like to hear them.