JonPSmith / EfCore.TestSupport

Tools for helping in unit testing applications that use Entity Framework Core
https://www.thereformedprogrammer.net/new-features-for-unit-testing-your-entity-framework-core-5-code/
Other
352 stars 53 forks source link

Look for appsettings.json in output folder #27

Closed junkbondtrader closed 4 years ago

junkbondtrader commented 4 years ago

Hi Jon,

I'd like to be able publish my test project to run on a separate machine. As far as I can tell EfCore.TestSupport will only look for appsettings.json up a directory from the /bin folder the .dll lives in.

Does EfCore.TestSupport allow the appsettings.json to live anywhere else? If not, are you opposed to this? Do you have any thoughts on how I might go about changing this?

Thanks, Andrew

JonPSmith commented 4 years ago

Hi @junkbondtrader (that's an interesting handle!)

To be pedantic the library looks for the /bin folder of the calling application. That does have problems in some circumstances, like issue #14, which you created (I assume you got that going - yes?).

My client is using my library in an Azure CI/CD pipeline and we can access the appsettings.json OK. So, why do you think it won't work on "on a separate machine"?

Happy to discuss this (when I have time) as I am open to ideas for a more robust to way to locate the appsettings file, but so far I haven't found one yet.

junkbondtrader commented 4 years ago

(I assume you got that going - yes?).

I did indeed, thank you!

So, why do you think it won't work on "on a separate machine"?

You're quite right - if I bring the whole source folder over things work as expected. I'm not sure what I was thinking...

That said, copying the entire source folder feels clumsy as opposed to just bringing over the publish folder. My best idea would be "Copy to Output Directory" the appsettings.json and first look in the folder containing the calling application.