VS2019 + Xamarin.Forms = UWP/EXE dropped? - templates

How do I get the UWP back into Xamarin.Forms Cross-Platform creation to have the templates ready to roll?
After picking through the release notes, playing with VS2019's UI and a few hours of web searching, I have only found others posting about the problem in the preview versions. Some say UWP is gone forever, some say it just isn't included by default (so Microsoft can brag about how the install went from 23GB to 8GB or something like that) - but no help on HOW TO re-enable it, or add it to the project creation wizard (apart from adding a blank UWP project sans all code that is in the iOS/Android projects).
<Project Sdk="Microsoft.NET.Sdk">
// the code is not the problem here,
// getting TO the code is the problem
</Project>
EXPECTED:
In VS2017, Xamarin.Forms Cross-Platform supplied iOS + Android + UWP templates by default.
ACTUAL:
Visual Studio 2019 seems to have removed the UWP template from Xamarin.Forms Cross-Platform project creation.

Update 9 apr.: a new version of 2019 was released which reinstates the UWP templates again
It is correct that the UWP template is removed from VS2019, I don't know the reason behind it, but we'll have to deal with it. There is however a page that runs you through the process step by step. It has been there for a while for the projects that were created in Visual Studio for Mac, which don't include the UWP template as well. The full description can be found here: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/platform/windows/installation/ taken from this page:
First, right-click on the solution and select Add > New Project... and add a Blank App (Universal Windows) project:
Then, select the minimum and targeted UWP versions.
Right-click on the UWP project and select Manage NuGet Packages... and add the Xamarin.Forms package. Ensure the other projects in the solution are also updated to the same version of the Xamarin.Forms package.
Also, make sure the new UWP project will be built in the Build > Configuration Manager window (this probably won't have happened by default). Tick the Build and Deploy boxes for the Universal project:
Right-click on the UWP project and select Add > Reference and create a reference to the Xamarin.Forms application project (.NET Standard or Shared Project).
In the UWP project, edit App.xaml.cs to include the Init method call inside the OnLaunched method around line 52:
// under this line
rootFrame.NavigationFailed += OnNavigationFailed;
// add this line
Xamarin.Forms.Forms.Init (e); // requires the `e` parameter
In the UWP project, edit MainPage.xaml by removing the Grid contained within the Page element. Then in MainPage.xaml, add a new xmlns entry for Xamarin.Forms.Platform.UWP, like this: xmlns:forms="using:Xamarin.Forms.Platform.UWP".
In MainPage.xaml, change the root <Page element to <forms:WindowsPage, like this:
<forms:WindowsPage
...
xmlns:forms="using:Xamarin.Forms.Platform.UWP"
...
</forms:WindowsPage>
In the UWP project, edit MainPage.xaml.cs to remove the: Page inheritance specifier for the class name (since it will now inherit from WindowsPage due to the change made in the previous step)
public sealed partial class MainPage // REMOVE ": Page"
In MainPage.xaml.cs, add the LoadApplication call in the MainPage constructor to start the Xamarin.Forms app:
// below this existing line
this.InitializeComponent();
// add this line
LoadApplication(new YOUR_NAMESPACE.App());
Add any local resources (eg. image files) from the existing platform projects that are required.
And now it should work as before. I know, it's a hassle to go through it for something that just worked before. Sorry about that, but this should get you there as well.

With the Update 16.0.1, Microsoft restored the UWP creation on new Xamarin.Forms applications
except when you try to use Shell, which is not available for UWP:
Issues fixed in Visual Studio 2019 version 16.0.1
Add option for Windows (UWP) platform when creating new Xamarin.Forms project from 'Mobile App (Xamarin.Forms)' project
template.

EDIT (7/17/2021): i have started a new xamarin forms solution and it seems all 3 platforms are available again in VS2019 on all prebuilt templates (blank, master-detail, tabbed layout).
thank you, everyone, for your input.
great information!
it helped me steel myself to face the fact:
UWP is gone (for now) from Xamarin.Forms new project scaffolding.
but, the (simplest) solution to the question asked that i have found is:
open VS2017. create new Xamarin.Forms cross-platform project.
once it is open, save-all.
then close VS2017 and open in VS2019 if so desired.

Related

Where is documentation for Core App C++/WinRT?

I am trying to develop apps in Core App C++/WinRT. I notice that it has a wWinMain entry point, so I am assuming it supports code from Windows Desktop Application. I cannot find documentation specific to Core App C++/WinRT. Should I be using the W32 documentation on msdn? When I try to add sample code from Windows Desktop Applications I cannot access header files such as winuser.h. I am using Visual Studio 2022, so the windowsapp.lib should already be included (I have also tried adding the windowsapp in a pragma comment directive). Can someone help?
Core App (C++/WinRT) is a project template for a Universal Windows Platform (UWP) app that doesn't use XAML. Instead, it uses the C++/WinRT Windows namespace header for the Windows.ApplicationModel.Core namespace. After building and running, click on an empty space to add a colored square; then click on a colored square to drag it. You could know about this from the document: Introduction to C++/WinRT.

Xbox 360 Wireless Controller is not working via C++/WinRT and Windows.Gaming.Input API in console application

I trying to use Windows.Gaming.Input API via C++/WinRT from Windows Console Application and it is not working as supposed with Xbox 360 Wireless Controller (reported as Xbox 360 Wireless Receiver for Windows (0x045e:0x0000)).
I got GamepadAdded event, then trying to read gamepad state via gamepad.GetCurrentReading() and seems GamepadReading struct is not filled at all for Xbox 360 Wireless Controller.
Also I found that there is some strange error message on MSVS debug console:
onecoreuap\xbox\devices\api\winrt\pnpdevicewatcher.cpp(500)\Windows.Gaming.Input.dll!00007FFE453AABC7: (caller: 00007FFE453AA367) ReturnHr(1) tid(4e04) 80070006 The handle is invalid.
Xbox One Game Controller (0x045e:0x02d1) is working fine though.
What is wrong with my code? Or this is bug in Windows?
Code is here: https://github.com/DJm00n/cppwinrtgamepad
Using Windows 10 1809, MSVS 2017 15.9.9, cppwinrt v1.0.190211.5, Windows SDK v10.0.17763.0, xusb22.sys v10.0.17163.1, xboxgip.sys v10.0.17163.1.
PS: I also tried UWP Simple3DGameXaml app from https://github.com/microsoft/Windows-universal-samples repo - and both controllers works in it.
This is a known issue. Apparently this is caused by how focus handling works. Windows.Gaming.Input basically doesn't work for console apps as a result, but does work for Win32 or UWP apps that have a window in focus.
Note that the one case where the Xbox One controller worked for you is only because both the user was an admin -and- because you had developer mode enabled. It wouldn't work from a console app at all otherwise.
If you need game controller support for a legacy Win32 console app, you should use XINPUT. See this blog post.
In order to help us investigate this issue more clearly, could you please share your Visual Studio 2017 version to us? You can get version info selecting Help -> About Microsoft Visual Studio, then selecting Copy Info from the right side of the About dialogue.
Could you please check if you can reproduce this issue on 1903 with SDK 18362?
By the way, it will be better if you can upgrade your project dependencies as well, what you are using is an old version of the Microsoft.Windows.CppWinRT NuGet package: 1.0.190211.5. The current latest stable version is v2.0.190722.3.
Besides, the C++ Language Standard was set in project properties, but the value was not set. This should be set to ISO C++17 Standard (/std:c++17) under Project Properties -> C/C++ > Language > C++ Language Standard.
Thanks for your collaboration.

MFC Ribbon app not displaying ribbon - when .exe is copy pasted to a different machine

Well, I am facing a strange problem. I have developed a sample MFC ribbon application on my machine - Windows 7 , with Visual Studio 2008. When I copy paste the .exe onto my laptop and run the app , I don't see the ribbon menu (in fact the app has not menu now) .
I have tried looking up the .dll that load in each case(on my work machine and laptop) using process monitor but I am unable to locate what I might be missing. Any help will be greatly appreciated.
Edit 1 -
Ok, So thanks for your responses. Some progress has been made with this issue
I changed my IDE to VS 2010. The ribbon was coded manually and I figured out if I could add it as a resource maybe the problem would be solved. VS 2008 did not have the option of adding a ribbon as a resource.
I installed the VS 2010 Service Pack Redistributable X86/X64 depending on whether the machine is 32 or 64 bit.
I built a new "ribbontest.exe" app from VS 2010 and deployed it on other machines on which I would test my actual app. The ribbon for "ribbontest.exe" loads without any problems.
When I deploy my app and run it, first the old menubar loads for a sec or two, then the ribbon flashes and disappears.
A little history of the app I am referring to -
Initially my application had the menubar view. I followed this article http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c14929/MFC-Feature-Pack-An-Introduction.htm to accommodate a ribbon.
Any suggestions?
Most likely there's a conflict in the settings 'paths'. In your InitInstance() handler, you've got a statement like this:
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
SetRegistryKey(_T("yourappname"));
If you haven't changed that name yet, do it. If you did, open regedit.exe on your target machine and remove the whole key under HKCU\Software\yourappname and then try again.
MFC stores user customizations of Ribbons/Menus/... under that key. But if you changed your app those settings don't necessarily match anymore and you can end up with stuff not showing correctly or not at all.
Make sure you download and install the Visual C++ Redistributable Runtime on your destination machine: http://www.microsoft.com/en-us/download/details.aspx?id=29
Or, something like it. Make sure you have architecture (x86/x64) correct and make sure it matches with the service pack version you compile with.
Joe is right: you need redistributable.
Joe is right: you cannot run 64-bit program on 32-bit machine.
All of the above would be indicated by the system (missing DLL, configuration incorrect, or 64/32 bit discrepancy)
Joe is right: your application must be built for specific set of minimum Windows version and service pack.
In addition to Joe’s post you must run release build not debug build.
If all of those requirements are met and you still have this problem, try linking MFC statically and see if problem persists.

VS2010 unable to add service reference

I have a project which was originally written in VS2008 (professional). I have created a vs2010 solution (using VS2010 professional) from the projects within the VS2008 solution but am not able to add a service reference from the domain layer of the solution (a class library project). I've checked that the domain layer project is targeting framework 3.5 or 4.0, and have tried repairing and even re-installing VS2010 but still cannot add a service reference.
The "service reference" option is missing when I right click the project.
There was also an existing "Web Service" reference which now fails when called during unit testing.
Has any one else experienced this problem ?
Check your project and make sure it is referencing framework 3.5 or higher.
View the project properties.
Go to Compile Tab
Click the Advanced Compile Options button
Look at the Target Framework combobox.
Change it to 3.5 or 4.
Click OK to close dialogs
Right click on project now.
For Visual Studio 10 in Windows 8. The "Add Service Reference" does not shown for 3.5 Framework or Earlier. You have to change the .NET Framework of Project to 4.0
Changing the Target framework to 3.5 enabled the option for me.

Coded UI Test Builder does not appear with setup project in solution

I am using VS 2010, and I was able to create a Coded UI test successfully, once. I am trying to do the same, but the Test Builder Dialog box does not appear anymore. I found the following post:
http://social.msdn.microsoft.com/Forums/en/vsautotest/thread/ff495f15-bb42-454d-88af-ae4d3bb4a075
This describes my problem somewhat. I do have a setup project, and when I remove the setup project and add a Coded UI Test, everything works. Then I add back the Setup project, and add a Coded UI Test, it works again.
Then I close VS 2010, re-open it, add a Coded UI Test, and the test buildor dialog bos does not show up.
Does anyone know of a fix?
VS 2010 SP1 solves the issue of creating Coded UI tests in solutions having a setup project.
For a description of VS 2010 SP1 (with a download link) see http://support.microsoft.com/kb/983509. Search for the title "FastForward/CodedUITest" to find doc that this particular issue is solved.