Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

.NET Core test project does not pick up settings from app.config or appsettings.json
samholder
#1 Posted : Tuesday, June 9, 2020 10:43:17 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/11/2012(UTC)
Posts: 79

Thanks: 24 times
Was thanked: 10 time(s) in 10 post(s)
I'm migrating a project that was on .net framework to .net core 3.1.

I'm used to behaviour where if a test project has settings in the App.config, those settings get 'transferred' to the app.config of the NCrunch test execution application so that they are available if the tests do a ConfigurationManager.Appsettings["blah"] or similar. This behaviour seems to have changed now, as the tests always get an empty result if they read the config when running with NCrunch. I've tried creating an appsettings.json file but i don't see this copied anywhere in the NCrunch test execution directory.

Is there something I need to be doing differently now?
Remco
#2 Posted : Tuesday, June 9, 2020 11:56:47 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,155

Thanks: 795 times
Was thanked: 1053 time(s) in 1002 post(s)
Hi, thanks for posting.

I'm personally unaware of anything particularly special that needs to be done to get settings working under NCrunch with .NET Core ... Although, I'm guilty of not being overly familiar with the settings model under .NET Core, and no one has asked me this question before. My guess is that there's something simple we're missing.

The first thing I'd recommend checking is whether you're able to build something that can use these settings outside of NCrunch. By taking NCrunch out of the picture, you can establish a clear baseline for that which you know NCrunch should be able to handle (you may have already done this).

The next thing I would check is whether the appsettings.json file is included in your project file or under NCrunch's 'Additional files to include' so that it gets copied to the workspace. I would presume that if the file needed to be in the build output directory, there should then be build steps that would copy it in there automatically.

1 user thanked Remco for this useful post.
samholder on 6/17/2020(UTC)
samholder
#3 Posted : Wednesday, June 17, 2020 3:44:07 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 5/11/2012(UTC)
Posts: 79

Thanks: 24 times
Was thanked: 10 time(s) in 10 post(s)
I've been able to load up the appsettings.json during the tests by doing it manually, which is sufficient for me for now.
1 user thanked samholder for this useful post.
Remco on 6/18/2020(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.028 seconds.