allantargino / kubeless-netcore-runtime

Implementation of a .NET Core 2.0 (C#) runtime for Kubeless
http://kubeless.io
1 stars 2 forks source link

Fix dependencies installation #4

Open allantargino opened 6 years ago

allantargino commented 6 years ago

references to https://github.com/kubeless/kubeless/issues/395

It should support a requirements.xml file, with this content like:

<ItemGroup>
  <PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
  <PackageReference Include="System.Net.NetworkInformation" Version="4.3.0" />
</ItemGroup>

A dotnet restore command would be triggered on startup by kubeless runtime.

mgernand commented 6 years ago

I have a function running that uses an external packages reference. The whole thing is just hacked right now. I need to generalize the approach.

I introduced an new IReferencesManager implementation for creating the necessary references. (This is hard-coded atm, because we need to find the correct path to the assembly in the packages folder.) It's a hack for now, but the faction compiles.

The next step was to load the functions references before executing the function, because the WebAPIs AppDomain does not have it loaded already. I just did the same with the hard-coded reference to see if the function executes successfully. And it does.

The last step is to make the docker container execute a dotnet restore in the kubeless folder. (To have the packages inside this folder we actually have to execute: dotnet restore --packages packages. I expect a *.csproj file in this folder. The problem with the container is, that the command dotnet restore is not available in the image microsoft/aspnetcore:2.0. Calling it yields:

Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
  http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

For now I just use the build image. I created a startup bash script that restores dependencies and after that starts the server. This prolongs the init time of the function with the time the restore takes.

mgernand commented 6 years ago

I implemented the metadata reference discovery using the *.csproj andobj/project.assets.json files. This works good, so this issue will be closable after my pull request.

mgernand commented 6 years ago

The references (packages) are discovered from the *.csproj and project.assets.jsonfiles.