0
votes

In my solution I have three projects. MainProject1 is of type UWP app, other two are Universal Window runtime components. UWP app project is dependent on other two for some functionality.

I want to share the two Universal Window runtime components project with a completely different project in different solution MainProject2. Is it possible for me to completely extract Universal Windows Runtime Components to separate package and consume them as dependency from both the solutions?

2
Why dont you add the projects you need to your new Solution? Then you can do a normal reference to them? - TheTanic

2 Answers

0
votes

It's simple. This can be done in two ways,

  1. Like the comments section advised, add the entire project into the new solution but this would make you do the changes in multiple solutions over and over again.
  2. The alternative is kinda convenient, it's what i use too. Below is what I do:

  1. From the first project solution (MainSolution1) add the new windows Runtime component and add some code. Now once you have your RunTime Component ready, shift the Mode from Debug to Release, (This would create the final output .dll in Release mode, would help you to avoid issues while publishing your app)
  2. Now into the solution explorer on your Runtime component right click and then ReBuild (Not on your entire solution, just on the runtime component).
  3. Once the rebuilding is completed, right click on the runtime component and then the third last option in the menu "Open Folder in File Explorer". This would take you directly where the RunTime component project is located on the disk.
  4. Now in Bin>x64(or whatever is your configuration)>Release> you'll find the .pri .pdb (these are symbols that help in debugging) and .winmd extention files. Copy these files to your new Solution (MainSolution2) folder under the folder name Packages (This is just a good practice) in the Packages folder create a folder named YourRunTimeComponentName and paste the files there.
  5. Now from your MainSolution2 go to references and add a new reference under Browse tab from the left click the Browse button on the bottom and in the FileExplorer navigate to MainSolution2>Packages>YourRunTimeComponentName> and then select the .winmd file. And that's it. It's done. You'll now be using the RunTimeComponent as a compiled library instead of an entire project.

Note: This would make it tough to debug the RuntimeComponent as some pieces of code might be internal or private.


The Screenshots:

Phase 1

Phase 2

Phase 3

Phase 4

Please note I have taken the liberty of hiding my folder labels and project information with a black bordered white overlay.

0
votes

My recommendation is to package the WinRT components as two nuget packages (one for each of the two projects), upload it to nuget.org and add them as dependencies for MainProject1.

Check out the Create UWP Packages guide to learn more.