Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more flexibility in locating projects when using FunctionsController #56

Closed
jongeorge1 opened this issue Mar 3, 2020 · 3 comments · Fixed by #91
Closed

Allow more flexibility in locating projects when using FunctionsController #56

jongeorge1 opened this issue Mar 3, 2020 · 3 comments · Fixed by #91

Comments

@jongeorge1
Copy link
Contributor

At the moment functions are started by supplying a project name to the FunctionsController. This is resolved by assuming that all projects, including the executing test project, are contained in a folder called Solutions. We should look at a way of making this work without forcing people to adopt a specific folder structure for their solutions.

@alastairs
Copy link
Contributor

Now that #83 is merged, I'm going to start taking a look at this issue (a pre-requisite for us to use the new library in our projects). I have these ideas in mind:

  1. Provide one of the Function classes as a generic parameter and resolve the function directory from that
  2. Provide the name of the Functions project, search up the directory structure until a .sln file is found (or a .git directory?), then recursively search the directory tree for the directory containing the project file with the specified name.
  3. Pass the root directory into StartFunctionsInstance(), which is a bit messy. Given we're already passing a path to the Function, the runtime version, and then adding the root directory too (and all as strings), we might as well pass the full path string to the Function's executable.

I'll spike out option 1. in advance of further suggestions and discussion.

/cc @jongeorge1 @idg10 on the assumption you each have an interest in this

@alastairs
Copy link
Contributor

So there's some things I found through spiking out the resolve-by-type that need considering:

  • The test project needs a reference to the function project. This was already the case with the Xunit demo, but not with the SpecFlow demo.
  • This will resolve the function project from the dependencies of the test project. We're still testing the built function project, but it's no longer coming from the function's project directory.

In the process, a further option has presented itself, which I think will be more robust (until and unless the Functions SDK changes this): the built function includes a file called function.deps.json in the directory $(ProjectDir)\bin\$(Configuration)\$(TargetFramework)\bin. While running func host start in that directory doesn't start the function properly (no functions discovered - missing the host.json I guess?), running the function from the parent directory obviously does (this is the directory we're currently looking for). So, I think my proposal for an implementation is:

  • Remove the path munging that currently exists
  • Do a recursive search for files called function.deps.json
    • (Filter the results to a function project name supplied as an argument?)
  • Run func host start from the parent directory of the resolved function.deps.json -- this should be the required $(ProjectDir)\bin\$(Configuration)\$(TargetFramework) directory.

@jongeorge1
Copy link
Contributor Author

I had wondered if we could get away with something as simple as just stepping up the directory tree until we got to a place where combining the current location with the path supplied to the functions controller resulted in a location that actually exists. Depending on your solution structure, you might need to further quality your function path. Would this approach work for your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants