2

I have a .NET class library project that targets UWP applications. I wish to re-purpose it to also support Xamarin.Forms applications.

Initially, I imagined that I could achieve this by creating a new .csproj file, in the same directory as the original, and configure it to reference the same set of source files, but with a different set of dependencies, as appropriate to the target framework.

However, this doesn't seem possible, since each of the projects expects its dependencies to be defined in a project.json file that resides in the project directory. If it were permissible to rename project.json to a framework-specific name, that would solve the problem. But, as far as I can see, the name and the location of project.json is fixed.

Is there a recommended way of creating multiple projects that reference the same codebase, but with different dependencies?

Weiwei
  • 3,674
  • 1
  • 10
  • 13
Tim Coulter
  • 8,705
  • 11
  • 64
  • 95
  • Why does it need to be different projects? A single project can have multiple target platforms (configured using the `"frameworks"` element in project.json). – svick Sep 28 '16 at 10:36
  • @svick That sounds like a very interesting solution, but I am not clear how I would make that work when the dependencies referenced in the source code resolve to different assemblies, depending on the target framework. For example, in UWP the definition for Enum is in System.Runtime, but for a Xamarin iOS project it is in the mscorlib implementation of Xamarin.iOS. If what you are suggesting is still achievable in these circumstances, it would be great if you could point me to a tutorial (and submit it as an answer, which I will accept). Thank you. – Tim Coulter Sep 28 '16 at 14:01

0 Answers0