I really hope this is just a dumb thing I'm running into, but I haven't been able to see my mistake for hours now. When trying to run func.exe host start from this repository, I get the following error:
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
Job host started
The following 1 functions are in error:
Git: The function type name 'Worker.Git.GetStatus' is invalid.
The directory structure:
.\Worker\host.json
.\Worker\Git\GetStatus.cs
.\Worker\Git\function.json
Function structure:
namespace Worker.Git
{
public class GetStatus
{
public static async Task Run(string gitRepositoryUrl, TraceWriter log)
{
}
}
}
And function.json:
{
"scriptFile": "..\\bin\\netstandard2.0\\Worker.dll",
"entryPoint": "Worker.Git.GetStatus.Run",
"disabled": false,
"bindings": [
{
"name": "gitRepositoryUrl",
"type": "queueTrigger",
"direction": "in",
"queueName": "git-processor",
"connection": "AzureWebJobsStorage"
}
]
}
cc @ahmelsayed
The CLI doesn't build cs files. You'd have to use msbuild for that.
building is not the issue...the build is fine. but, targeting the .dll and specifying the entrypoint is not locating the method at runtime
{
"scriptFile": "..\\bin\\netstandard2.0\\Worker.dll",
"entryPoint": "Worker.Git.GetStatus.Run",
//...
}
ah I figured I must be missing something. Give me a minute to try that.
@jaredcnance I wonder if it has something to do with targeting .NETStandard 2.0. @fabiocav do you know if the current runtime should be able to load .NETStandard 2.0 assemblies?
btw, I couldn't build your project targeting .NETStandard 2.0, it was complaining about LibGit2Sharp namespace not being defined, not sure how you got passed that.
Ah I can't believe I missed that. I bet the netstandard directory is an artifact on my local machine from before I brought in that package and the only thing being built is against FF. Will double check when I get home. Sorry I made you dig in for that.
yeah...so it is a new build and not an artifact. msbuild does give me the expected warning:
Worker.csproj : warning NU1701: Package 'LibGit2Sharp 0.24.0' was restored using '.NETFramework,Version=v4.6.1' instead the project target framework '.NETStandard,Version=v2.0'. This may cause compatibility problems.
but, it builds fine which is kind of weird. I just did a fresh clone to a new dir:
git clone https://github.com/jaredcnance/dotnet-status.git && git fetch origin && git checkout mongo-dbdotnet restorecd workerdotnet buildand it builds fine. but, i expect this may be causing some issues when the runtime is trying to load the assembly? i added net462 to the target frameworks and then pointed at that dll instead and it works fine. so the issue seems to simply be a lack of information from msbuild? or not failing when it should? i'm really not sure yet.
@jaredcnance When you create a project using the tooling, it will create it with the target framework of net461, which is required. We don't have the .NET 2.0 binding redirects available in the runtime, which is why a netstandard 2.0 library won't directly work.
Here's an example project: https://github.com/Azure-Samples/functions-dotnet-codercards/blob/master/CoderCards/CoderCards.csproj#L4
Ah I see...good to know. Thanks