-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MonoGame.Portable returns - now with Piranah's #3405
Comments
What's the point of having a PCL version of MonoGame? Is it a stripped-down version that allows you to turn a subproject into a PCL even if it uses something like Vector2? |
Used for the bait-and-switch technique where you use NuGet to add the PCL |
I still feel like this personally. Even bait-and-switch requires the same or more csprojs to make it work. But some people still like it which is why we are going to support it. |
@Nezz PCL's solve two distinct problems with multi-platform dev. 1: No file linking / copying required, it's a single project. While both file linking / copying work fine, they do require maintenance to add new files or remove files from all projects over time. 2: Core compatibility. Any code that is in the PCL is guaranteed to be compatible with all platforms, no need for #IF's or other code to manage all the different platforms within the PCL. It will also restrict you from using code that will break some platforms, plus it also abstracts some basic features to ensure code is compiled specifically for a certain platform. Further details here: http://darkgenesis.zenithmoon.com/monogame-building-portable-solutions/ But as Tom said, it's a choice. Some devs use it a lot, other veer away from it and prefer other methods of maintaining a cross-platform solution. If you are only targeting one platform, then you never need use or worry about it. |
Thanks for the support @KonajuGames & @tomspilman So Thoughts? |
First lets wait to get 3.3 out before we go further with PCL. I plan for this to happen soon... in the next week. After that we need to add the Piranah.exe to a folder in the dependencies repo.... https://github.com/Mono-Game/MonoGame.Dependencies ... then you can update the default.build script to trigger running Piranah.exe on the WindowsGL assemblies in question. Finally we need to update the installer to install the PCL assembly and probably need to add a PCL template of some sort. |
@tomspilman with regard to 3.3 , the VS templates will need updating for On 16 January 2015 at 08:11, Tom Spilman notifications@github.com wrote:
|
Sounds good to me. |
We have also been working on a MonoGame PCL version. I would like to share my experience to show how useful a PCL version of MonoGame can be. How it was created: How it is used: Some more notes: I soon need to revisit our MonoGame version for tests on WP 8.1 and iOS 64-bit. Then I could also clean up our PCL version and prepare a pull request -- to let you compare our PCL approach with your PCL approach. |
Interesting @Helikin , that is the same pattern as I used for the original PCL version of MG. This move is to create a generated "core" solution without the platform variances for now as in testing across several solutions, it made more sense to only use those variants on the platform rather than in the PCL (it just made it over complicated) . |
Nice! |
@DDReaper What is the difference between the core PCL and the holistic/full PCL? Does the core PCL contain any stubs for platform-specific classes, like GraphicsDevice, GamePad, OcclusionQuery? |
Right, probably my bad terminology there. The only concern or gap I potentially see is that the Compass and Accelerometer classes are still separate. This would need addressing in the future. SO at present you would need to abstract this in your Platform project and "send" it to the PCL code. (also allows for special exceptions per platform) You can test this generation of the package here - https://www.dropbox.com/s/797nxyy5vwsotlh/MonoGame.Portable.3.2.3-alpha.nupkg?dl=0 |
Ah, I understand. I think we are talking about the same API set and the Core API is all we really need. I dropped the PCL DLL from the package into our projects and it seems to work fine. Great job! |
This Bait and Switch approach sounds really good for complex multi-csproj games. I'll definitely give it a go on my next game, and see what happens. |
With bait and switch I've had between 90% 100% shared code between multiple platforms. Plan on doing more education material in this area once it's up and running again. P.S. the existing MonoGame-portable package has been used quite extensively already, this is just the final move to bring it under the MG banner fully. |
Thanks @DDReaper , I have used PCL from your shared nupkg. It works perfectly. Since my game is quite and does not used XNA extensively current state does the job for me and i might as well go to production with this unless i face any issues. |
Can I request a PCL & Nuget for the MonoGame.Framework.Content.Pipeline assembly. I just finished off a XS template for a Pipeline extension project, a nuget would fix the references :) |
Will look to creating that @dellis1972 |
I just wanted to pipe in here and say that this is the point of using PCL's:
I don't think the value of this should be under-estimated. This issue bothered me so much that I stopped using MonoGame completely and created my own game framework from scratch. I'm not suggesting people use my framework over MonoGame. I'm first to admit that my framework is not even close to being as complete as MonoGame. However, I just wanted to point out that there is a better way. It is 100% possible to create a game framework that uses PCL's at the core and makes multi-platform development an absolute pleasure. I'm not even going to take credit for this, LibGDX has been doing it this way for years with great success. Even though I've got my own game framework separated from MonoGame I've still very much love to see MonoGame go this way. It would make it possible to write various extensions to MonoGame much more easily and I could take the work I've done in my own framework and combine it with MonoGame to give everyone the best of both worlds. As it stands, writing any kind of MonoGame extension requires that the extension is recompiled for every supported platform. This really sucks, and stands in the way of some really great things happening in the MonoGame community (like physics, GUI libraries, particle systems, etc). |
I reference MonoGame.Framework.Portable (3.2.99.1-beta) in a Windows 10 Class library |
@DDReaper, @tomspilman, @KonajuGames Would it be possible to merge this and release the installer and packages? |
Once it's ready for release. a little ways to go yet 💃 |
So what remains to get this ready to include? |
@DDReaper Cool! Are you working on this at the moment? Cannot wait! 😌 |
Interesting:
|
I haven't read the full post yet but this is seems like excellent news for PCL's. Awesome. |
@hach-que - It is possibly stuff we've defined for Win10 in the custom xslt files. We need to make sure we get these changes back into Protobuild. |
@hach-que the protobuild generation works fine. But when you try to then open any solution, you get the error in VS. |
Ah yeah, it's because upstream I changed |
I've sent through a PR which updates Protobuild to the latest version so this PR can be updated. |
Is it likely to be a part of the recently announced next release? |
OK, so moved on with the .Core project after the ProtoBuild update, however no further along it seems. On evaluation with the test project (which works), it seems when you have a platform name (which is needed for MG) it ignores the project? Any ideas @hach-que ? |
You need to change the platforms tag to include all platforms. The |
Also you almost certainly do not need to include GUIDs in this new project, so you can (and should) omit that entire section. |
Already have the ForcePCL property defined in the Build file for the library. <?xml version="1.0" encoding="utf-8"?>
<Project Name="MonoGame.Framework.Core" Path="MonoGame.Framework" Type="Library" Platforms="PCL">
<ProjectGuids>
<Platform Name="PCL">44FDC7D0-CE78-4826-8F14-81C8A2455A00</Platform>
</ProjectGuids>
<!-- Common assembly references -->
<References/>
<Properties>
<NoWarn>1591,0436</NoWarn>
<MonoDevelopPoliciesFile>Build/MonoDevelopPolicies.xml</MonoDevelopPoliciesFile>
<RootNamespace>Microsoft.Xna.Framework</RootNamespace>
<RemoveXnaAssembliesOnWP8>false</RemoveXnaAssembliesOnWP8>
<PlatformSpecificOutputFolder>True</PlatformSpecificOutputFolder>
<CustomDefinitions>
<Platform Name="PCL">PORTABLE</Platform>
</CustomDefinitions>
<Property Name="ForcePCL" Value="True" />
</Properties> |
Also note @hach-que that I took your ForcePCL test project, added the Platforms tag definitions to the <Project definitions, this also prevented your sample from working As if the Platforms tag interferes with it's ability to reference the PCL. If I remove the Platforms tag from the PCL lib here, it causes ProtoBuild to generate a project PER platform, which is obviously not desired. There should only be one PCL csproj generated. |
No there will always be a project per platform, because there's always a single platform for the entire project hierarchy that's generated. The The resulting assembly is the same across all platforms, it's just the project file name that's different. |
When you set Platforms="PCL", this means that Protobuild will not generate or reference the project if the platform is "Windows". So you want to remove that Platforms tag entirely (it will still be a PCL project though). |
I agree with your thinking @hach-que however the output doesn't meet expectations. <?xml version="1.0" encoding="utf-8"?>
<Project Name="MonoGame.Framework.Core" Path="MonoGame.Framework" Type="Library">
<Properties>
<Property Name="ForcePCL" Value="True" />
</Properties>
<References>
<Reference Include="System" />
</References>
<Files> If you have a minute, feel free to download my branch fork and run protobuild yourself to see the result. Could it be that when a project that HAS a platform assigned, is overriding the ForcePCL flag? That's the only difference I can see between MonoGame's implementation and your test sample. |
As a side note, as MonoGame shared it's assemblyinfo across all projects, the following Custom definition is needed on the PCL project <CustomDefinitions>
<Platform>PORTABLE</Platform>
</CustomDefinitions> Would this still be available or would it need it's own? |
If MonoGame isn't using the latest XSLT files, then All this flag does is force the project to be generated as a PCL project; it doesn't change the platform name. This is a limitation of the way Protobuild works; there is one platform active during generation, and this platform name is constant between all project generation. It's not possible for one project to have a different platform because it introduces significant complexities in determining the path for other project references (especially when considering external projects as well). However with the When distributing the binary, you can pick any of the assemblies generated from those MonoGame.Framework.Core projects for distribution; they are all identical. |
I just checked the XSLT, and you'll need to do: <CustomDefinitions>
<Platform Name="Android">PORTABLE</Platform>
<Platform Name="iOS">PORTABLE</Platform>
<Platform Name="Linux">PORTABLE</Platform>
<Platform Name="MacOS">PORTABLE</Platform>
<Platform Name="Ouya">PORTABLE</Platform>
<Platform Name="PCL">PORTABLE</Platform>
<Platform Name="PSMobile">PORTABLE</Platform>
<Platform Name="Windows">PORTABLE</Platform>
<Platform Name="Windows8">PORTABLE</Platform>
<Platform Name="WindowsGL">PORTABLE</Platform>
<Platform Name="WindowsPhone">PORTABLE</Platform>
<Platform Name="WindowsPhone81">PORTABLE</Platform>
<Platform Name="Web">PORTABLE</Platform>
</CustomDefinitions> |
@hach-que - Actually it would be good for you to pull the changes we've made in our XSLTs into Protobuild. These are mainly just changes to support Windows 10... https://github.com/mono/MonoGame/commits/develop/Build/GenerateProject.CSharp.xslt ... you probably want some or all of these changes in Protobuild. I just haven't had time to submit a PR to Protobuild for this myself. Anyway... if Protobuild has Windows 10 support we could probably drop the XSLTs we have. |
I had a look to see if I could recreate the changes you've made @tomspilman and create a PR for protobuild. But unfortunately there seems to be too much variation between the current xslt's used in MonoGame to the masters currently in Protobuild. Any change @hach-que you can cherry pick the Win 10 fixes, then I can simply take the new masters as part of this change? Granted, I know you are both up to your eyeballs with stuff at the moment. |
*edit I've replaced the MG versions with the new updates and tested against the develop branch and noted no issues in the Windows 10 build. My only reservation (which I've noted in the Protobuild commit) is that I'm not sure about naming Windows 10 as UAP, since the proper Windows 10 definition is UWP. Should UAP still be used or should it update to avoid confusion? |
Also this is tangentially related to Protobuild in MonoGame, but you might find it useful - I added post-build hooks recently which allow you to perform steps after building. Potentially MonoGame could have a project that executes a Pipeline build for all content project files in a project after the assembly is built, so that content is automatically built for anyone using MonoGame with Protobuild. All this requires is added |
Looks like the Core split isn't going to make the 3.5 milestone as the Protobuild update has been removed from the 3.5 milestone. |
Right #4282 has been merged now, so the .Core project should now work. |
now that the Protobuild updates are merged, reverified new .Core project PCL configuration, separating non-platform specific code in to a separate PCL lib (except Linux). |
Replacing this issue with one that is more easy to understand #4689. Let me know if I missed something. |
Right, so I've been working with @dellis1972 on the PCL generator project and it looks like it is close to being done.
It now uses a PCL generator solution based on Mono.Cecil called Piranah (which Dean has also updated to run on a Mac)
Generator branch for MG can be found here: https://github.com/DDReaper/MonoGame/tree/PiranahPCLGenerator
The generator only uses the WindowsGL build as a template, which seems sufficient for the PCL to be used in a "Bait and Switch" style PCL as a core platform. Platform specific code should always remain in a Platform project (like iOS), where as all common "core" code should be used in the PCL.
Question is now how to provide this framework back in to the MonoGame project so it can be run in an automated fashion. In the branch above (using Protobuild as a template) I've created a new ThirdParty folder for Piranah and put the runtime exe and Dll's in there.
There is a commandline file to generate the project manually for test at the moment (need both the WindowsGL project built and an output folder in MonoGame.Framework/bin/PCL created first)
I've also started on a new MonoGame.Portable NuGet package, which is still a work in progress. In testing it needs more platform targets to work effectively.
So next steps?
The text was updated successfully, but these errors were encountered: