Open j3parker opened 5 years ago
I've got this broadly working but it doesn't make sense to check in until we support net48
+ netcoreapp2.1
(the newest target frameworks that can produce exes).
I'm still investigating how runfiles work under the hood to see what stuff we have to DIY.
Normally in C# you put all of your DLLs in one folder, and they are loaded based on filename (the full details are more complex).
In Bazel, when you have a target with dependencies in a different folder it will fail to run because the DLL can't be found.
Solutions that probably won't work:
app.config
: you can use<probing>
to add subdirectories for the loader to consider. The problem is you can't use..
so this won't handle all cases.What I think will work:
Have an extra action that produces a shim exe, and also write the real exe path and the list of transitive dependencies to a txt file. The shim exe's
Main
function:Path.GetFilenameWithoutExtension
to the path to the DLLAssemblyLoad
event and uses the list from (1) to resolve DLLsMain( args )
(caution:Main()
vsMain( string[] args )
.. the runner would need to do the right thing).In our
DefaultInfo
for executable rules we point at that shim, with the txt file as a runfile.This probably makes sense to do after #8 because we should only need to make this exe once (probably for the latest .NET Core version?) but we could also do it for just .NET Framework first too.