In the spirit of open source (and to pay it something better than lip service)
NandoTech has published our first open source utility that we are using in-house. The application in and of itself is nothing special and doesn’t do anything particuarly complicated, but it solves an important problem for us while having the added benefit of possibly helping someone else with a similar problem.
NandoTech | Twilio |
---|---|
The utility we’ve released is a Twilio Call Importer which essentially just goes out and grabs all SIP call logs from Twilio and then saves them in batches of 1,000 to [SQL Server](), but there are serveral guides showing how you can configure Dapper for other databases very easily around the web. There’s guides for MySQL, Postgres and MongoDB that you could easily adapt for your needs.
I think what this has really done is actually inspired me. Currently, there is no .NET Core Twilio API either officially from Twilio nor unofficial. I think I may take a crack at writing a relatively complete wrapper for the entire Twilio API, preferably using 1. their new API version and also 2. following conventions similar to their previous .NET API or their current new ones.
Before I finish going completely off track: there is a huge “gotcha” in publishing .NET Core Console applications that I was completely unaware of and actually had a bit of trouble googling. When you dotnet publish
or publish a core Console app from Visual Studio, you do not get any .exe
or other executable file from your build. You do get a .dll
which contains your program, but counterintuitively dotnet run
does not work and results in errors.
So as I mentioned, I have a fairly basic console application. To be clear,
and that’s it. You can see the code really doesn’t have a ton of stuff in it. As of this writing, I didn’t even bother adding in any logging that could be helpful and basically comes for free. As for the project.json
:
project.json
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.Extensions.Configuration": "1.0.0",
"Microsoft.Extensions.Configuration.Abstractions": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.DependencyInjection": "1.0.0",
"Dapper": "1.50.2",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
When we publish this app, whether you follow Visual Studio prompts or the command line, you will end up with this in your folder.
So…since there’s no .exe
… dotnet run myproj.dll
right? Immediately, you’ll get an error about missing project.json
and appsettings.json
. I found no documentation on this, however I personally had to manually copy the .json
files directly to my server where this application ran. So we try again.
What gives? After a bit of googling, I came across this GitHub issue. Although the issue is closed, the “error” still persists and you have to continue using the workaround described there.
That workaround (after manually copying appsettings.json
and project.json
and manually dotnet restore
), is to use the command dotnet yourapp.dll
. So in the case of our application, dotnet TwilioCallsImporter.dll
.
And that is all. Your console app should be off and running. Just for posterity, see our completed console app run after pulling down our last 7 days of calls from Twilio:
Pretty cool, right?