0

I have these 2 solutions with this structure

Solution1

  • UI
  • Data
  • ClassLibrary

Solution2

  • UI
  • Data
  • ClassLibrary

Solution1 and Solution2 have their own appsettings.json called sone.json and stwo.json located in their respective ClassLibrary projects.

However, when I run Solution2 and reference Solution1, I get an error that says that the application can't find sone.json using the basepath of Solution2. How can I specify that sone belongs in Solution1? Can I hardcode the path for it?

JianYA
  • 2,750
  • 8
  • 60
  • 136
  • Nope. You can't. – Tân Nov 15 '18 at 13:37
  • What are the options I have then? Should I just have one common appsettings.json file that all my applications will use? – JianYA Nov 15 '18 at 13:42
  • It will match the path of the main project. So, if the main project doesn't contain `sone.json`. It would complain like that. – Tân Nov 15 '18 at 13:46
  • But what can I do if I want to reference another application that has its own appsettings.json? – JianYA Nov 15 '18 at 13:52
  • I saw that you wrote: `another application`. So, another application means it has *another url*, right? You can download json from the url. Ex: Main project url: `localhost:44300`, reference project url: `localhost:5000`. You can download the json file from `localhost:5000`. Reference link: [How to get a json string from url?](https://stackoverflow.com/questions/5566942/how-to-get-a-json-string-from-url) – Tân Nov 15 '18 at 13:56
  • Sorry I'm confused, What I'm trying to do is make sure that if Solution1 is being referenced by Solution2, the path to Solution1's appsettings.json is the basepath of Solution1 instead of the basepath of Solution2. – JianYA Nov 15 '18 at 13:58
  • I can only think about moving all of the json files to the main project. The reference project can still use them even if they're in there. – Tân Nov 15 '18 at 14:10
  • But even if I do that, if I run the second project, it will only know how to run the second projects basepath and not the main projects basepath – JianYA Nov 15 '18 at 14:20

0 Answers0