How can I activate Xamarin.Android for use on a CI server? - xamarin.android

My company owns several business licenses for Xamarin.Android, and we'd like to use this on our CI server. However, it seems that I'd need to install the full Xamarin suite on my CI server including Visual Studio Pro to make this work. My question is, using the vanilla Xamarin.Android package, how can I activate it?
It seems that installing this on its own adds the Xamarin.Android tools and libraries to build with but there is no way to activate it that I can find, so when I attempt to build using MSBuild, the build fails with this error:
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(299,2): error XA9008: Building from the command-line requires aÿBusinessÿLicense.
Now, after some googling, I have found that the activation tool is called "mandroid.exe", which can be found in C:\Program Files (x86)\MSBuild\Xamarin\Android - although I have found references to this being in the 64-bit program files too.
Unfortunately, I can't find any suitable documentation on this tool. Every time I find a thread where someone discusses this, someone from Xamarin jumps in and says "contact support#xamarin.com". After a while I did that but two business days later there still is no response and I've got deadlines to meet so I thought it might be helpful for everyone involved for us to publicly document this process.
The best thing I've found comes from a thread on the Xamarin mailing list which references this invocation:
mandroid.exe --activate --name "NAME" --company "COMPANY" --email "EMAIL" --phone "PHONE" --code "ACTIVATION CODE"
I have also discovered another variant of this invocation that looks like this:
.\mandroid.exe –activate –activation-name="NAME" –activation-phone="PHONE" –activation-company="COMPANY" –activation-code="CODE" –activation-email="EMAIL"
I've tried many permutations of my account data here using both invocations - using the activation code from the products page on the Xamarin store. No matter what though, this error occurs:
\mandroid.exe : monodroid: error XA9997: Incomplete data provided to complete activation
In the "problems activating?" section of the products page, it says this:
In Mono for Android 1.0.21316 and later, if activation within Visual Studio fails then a MfaActivation.dat file will be created within the Documents folder. Select this file below.
Perhaps there's some way to force this file to be created by mandroid.exe? That would be very helpful. While I imagine that offline activation is the only way to make this work, I would accept any answer that involves uploading MfaActivation.dat or otherwise invoking the online activation machinery as well.

Update - I'm afraid that the below steps no longer work. Xamarin has updated their activation system to activate by a different method for newer versions.
In the end I had to install Xamarin Studio as part of the Chef configuration and just instruct administrators to manually activate the software as part of creating a new build node. I had no luck trying to reverse engineer a fix, and if I did, it would probably just break again.
It turns out that I almost had it correct. The second invocation I specified is actually the correct way to call this command but the -- part was apparently converted to a – token by some blog software somehow.
The --activate verb will perform an online activation with Xamarin's servers, so I'm still not sure how you'd do it without an internet connection.
For reference, here is how I did it:
mandroid.exe -v --activate --activation-name "(NAME)" --activation-phone "(PHONE_" --activation-email "(EMAIL)" --activation-company "(COMPANY)" --activation-code "(CODE)"
I'm not sure about the significance of the -v switch, but perhaps that would make it output debugging info if there was a problem.
You must enter all the information exactly as specified on your products page - select one of your licenses and select "problems activating?". However, you will need to enter the licensee name - i.e. the user who owns the license in the --activation-name parameter which must correspond to the --activation-code parameter.
After doing this you can call mandroid with the --activated switch which returns an exit code:
PS> & .\mandroid.exe --activated
PS> $LastExitCode
0
You will also be able to reload the products page and you should see that your license for the chosen user has a new computer registered to it.
This does use up another activation but if you e-mail the support team you can sign the build server agreement and then I assume they can set you up with additional activations for your build nodes.
It's a shame that this wasn't documented better because this has wasted my time for several days. Hopefully this will be helpful to someone else with the same situation.

From Xamarin documentation, we can see
http://docs.xamarin.com/guides/cross-platform/ci/configuring_tfs/
"Visual Studio Professional (or greater) must be installed on the Team
Foundation Server along with licensed copies of Xamarin.Android and
Xamarin.iOS to support development of Android and iOS mobile
applications via the Team Foundation Server."
So I assume that in all cases you need to have VS + Xamarin products installed and activated.
I might be wrong, so the best way is to contact Xamarin support, http://xamarin.com/support

Related

I'm trying to create an auto installer bot

I will place a fold with the installer in desktop then automate the installing process. Does the bot will also wait if the pc lags?
Why do I need to submit email/license etc every time I open the app? Please create a proper installer and how to create an executable problem without opening the g1ant edit?
G1ANT robot always finishes one action before it starts another one, so you don't have to worry about any PC lags.
Entering your email is required when you haven't yet activated G1ANT.Studio on your computer and it should happen only the first time or when you want to change your license.
Entering license key in order to open the G1ANT editor is required due to security reasons. This way you can make sure that only RPA developers can change your G1ANT code and no one unauthorized who doesn't know the license key can use it. But this feature is only in the production version. Developer version doesn't have this protection.
What do you mean by "proper installer"? G1ANT.Studio is so light (it weighs less than 150 MB) that .msi is not needed, you can just download it from G1ANT website and use it without any installation right away.
The G1ANT editor doesn't have to be opened for the scripts to be run, triggers work correctly if they're activated and G1ANT.Studio is running.

Error 1001 when installing custom Windows Service

I wrote a windows service that runs on Framework 4.0 and running in VS 2015.
I also created a setup project (free Installshield version).
My service did not show under services.msc after I installed it, so according to some other posts I had to mark the Primary Output in InstallShield as 'Installer Class', but when I do that I get Error 1001 when I run the setup.exe.
This post states that "Error code 1001 ALWAYS means a failure in the Installer class custom action." and that I should not use Custom Actions. I'm not using any custom actions at the moment.
Most of the solution on this site have instructions for Installshield 2010, and the steps does not work for 2015.
The error appears on both my dev machine as well as all client machines.
Any suggestions?
EDIT:
The event viewer displays "Failed to create restore point (Process = C:\Windows\system32\msiexec.exe /V; Description = Installed My App Name.; Error = 0x80070422).
I had this exact same issue. Suddenly after upgrading to VisualStudio 2013 and the newer InstallShield LE and building my installation packages they would fail with the cryptic 1001 error.
Definitive Answer
I found the definitive answer. You can no longer have the checkbox for "installer class" selected in InstallShieldLE. You must uncheck that item.
In order to open this dialog box, go to Specify Application Data > Files and right click on your Primary Output and select Properties.
Previously, You Had To Have It Selected: Now It Must Not Be Selected
Previously (Visual Studio 2012 and before you had to have that item selected or the service installation would fail. This is quite terrible.
Now, you have to go to following tree item in the InstallShield LE project and double-click the Services node:
After that the Services item appears on the left (have I mentioned what a terrible UX and UI this entire thing is?) and right click it so you can add the service.
Choose the menu item which appears to add the service and you'll get a form which allows you to set up the installer details.
Once you do that and rebuild your MSI will work and this will resolve the 1001 error.
This was all a terrible waste of time that the original InstallShield Devs could've resolved. Unfortunate.
If you have .NET 4.6 installed on your build machine, you'll need the 2015 version of the limited edition to avoid a versioning bug with InstallShield's support for Installer Classes. (There are many causes for a 1001 error, so this is not a guaranteed fix.) Note that InstallShield 2015 Limited Edition does not support the community edition of Visual Studio.
Hopefully this will help some of you encountering the Error 1001 when trying to install a .NET Windows Service using InstallShield 2015 LE installer project with the Primary Output set as an Installer.
It's a known bug when .NET 4.6 is installed on Windows 10.
https://flexeracommunity.force.com/customer/articles/en_US/ISSUE/HOTFIX-Install-Fails-With-Error-1001-When-a-NET-Installer-Class-Component-is-Present-in-InstallShield-2015-SP1
Since i cant comment yet i will just reply with an answer to your own accepted answer. I know it has been a while since you asked the question but here goes.
If you want auto start after install you can go to step 3. Configure the Target System. Choose the Services tab. Right click Services and add Service. You should be able to locate any service in your Primary Output. Once added you can select different settings related to auto start and so on. Hope it helps you.
On a side note, i am still looking for the answer to my 1001.
This error occurs when targeted .NET framework is not installed.
If you are targeting the same development machine then please check if that service (EXE) is already running on that machine or not (It should not running).
I found something to get rid of the problem, but it does create a new question, albeit a much simpler and less critical one.
What caused my problem is that I had to remove the following code from my ServiceInstaller's AfterInstall:
new ServiceController(ServiceInstaller.ServiceName).Start();
This was added to auto start my service once it has been installed. For now I will just manually start the service.
I am using VS 2012 with InstallShield LE 2015 targeting .NET 4.5 and I have to uncheck the "Installer class" for it to work.
After some digging I found out that the installer fails with that error when it tries to remove the service (associated with whatever you are installing) - AND (the service) is not there anymore.
My use case scenario - Start install from MVS2015 of a complex solution that comprises also a windows service.
When you change the version of the solution, the installer stops in its tracks finding that the your app was installed before and can not uninstall it as it is a different version. It pops up a dialog box stating this and exits .... BUT IT HAS UNINSTALLED the service.
Now trying to install or uninstall fails with the error 1001 because windows doesn't find the service to uninstall it.
If somebody has a better solution please post it, but my solution is to use sc command line utility. sc is a utility that can be used to manipulate services from the command line (type sc for help). So i use sc to add the service (by name), and then I can do uninstall, or install as usual. Is compulsory to have a valid bin path in command - but ANY valid path will be accepted.
sc <server> create [service name] [binPath= ] <option1> <option2>...
Example:
sc create MyService binPath= C:\Windows\explorer.exe
[SC] CreateService SUCCESS

Updating own software in Program Files

I have a single executable which, via InnoSetup, installs into Program Files\FolderName by default. The exe has a 3rd party component which goes online to check for new versions and downloads them, then does a bit of fiddling to replace the exe - simple stuff. The problem is, it can't do this in Program Files because of the necessary security there. I was reading Windows 7 - Can't update my program's files in C:\Program Files in which David Hefferman gives a solution but then seems to say it's a bad idea - but I don't know whether the bad idea bit refers to his solution or to the OP's comments!
So what is the preferred method by which a program can update itself? One that will work on XPSP3 to Win8. I can't seem to find the right phrase to enter into Google that gives me relevant results. Ignore digital signatures and suchlike for now, for simplicity.
(Please note, it may look like I worded that as an opinion question but it's not - there must be some MS-endorsed way of doing it that I can't find. FWIW this is a Delphi program but any Win32 notes will do)
That 3rd party update utility needs to be run with administrative privileges, you can achieve that programmatically.
There is nothing wrong with installing your application in Program Files, that is the designated purpose of this folder. However, user data that is used by the application should be stored in a different location.
However you run that 3rd party Utility, you should first check the Windows OS version to see if fiddling with UAC is really necessary(Vista+...) and then run the utility in the elevated state.
He says its "extremely bad practice" to fiddle with your system so that normal users can write in "Program Files".
If your program is in "Program Files" it's installed with System Admin rights. So updates need also be installed with System Admin rights.
You can configure InnoSetup to request admin-rights so you can write to "Program Files" but if the 3rd party component does not do this its best to install everything in an other directory.
i.e. C:\Your_Program
That way your 3rd party component can write there.
There are several options here:
The easiest: make updater as a separate program with manifest, which requires admin privileges. Also you can ask for admin privileges when you start your updater. Or you can move your updater into out-of-process COM object instead of separate exe.
You can create hidden user with admin rigths during installation of your program. Then you will run your updater with credentials of this user.
You can install system service during installation of your program and this service will run from system account. So your updater will be implemented as a service.

debug ASP.NET MVC system code in Azure Compute Emulator

I'm developing an ASP.NET MVC (still v2) Azure web application. I've run into a problem that seems to require me to step through the MVC code itself. I can do this but also need to be able to inspect the code as I step, so I need to be an unoptimized version (so as to not get the "Cannot obtain value of local or argument ...") message in the debugger.
The standard way of circumventing the optimizations (http://blogs.msdn.com/b/sburke/archive/2008/01/29/how-to-disable-optimizations-when-debugging-reference-source.aspx) doesn't seem applicable to running in the Compute Emulator.
I also tried this by creating a local debug build of the System.Web.Mvc project but my web role hangs when I try to start it in the Compute Emulator.
So ... Any help with either of the following would be much appreciated:
Running an Azure web app in Visual Studio (2010) so that it will ignore code optimizations in system dlls.
OR
Creating a local system debug build so that it can be referenced by an Azure web app being debugged in the Compute Emulator.
If the Azure Compute Emulator is giving you issues you could run your MVC project using IIS Express. Just right click and and Select Debug/Start New Instance.
I was finally able to get unoptimized ASP.NET code while debugging in the compute emulator. The basic approach described on MSDN (http://msdn.microsoft.com/en-us/library/9dd8z24x%28v=vs.100%29.aspx) and elsewhere (http://martin.bz/blog/asp-net-mvc-source-debugging-the-easy-way among others) is to put an .ini file that tells the JIT compiler not to optimize in the same directory as the DLL.
The first challenge was to determine just where that was; it finally dawned on me to watch the logs in the Compute Emulator UI and see where they loaded the DLL (in this case System.Web.Mvc) from.
The second challenge was getting the .ini file there. Windows Explorer didn't work because it uses a different way of viewing assembly caches that doesn't give you direct access to the files. One of the posts I read reminded me that using the Command Prompt might give me that access and it did. The last step was realizing, when the Command Prompt wouldn't permit me to move the .ini file into the assembly directory, that I needed to run Command Prompt as admin.
Once I could view variables while debugging, I pretty quickly realized where my bug was.

XNA 4.0 ClickOnce game does not run after installation

Okay, I have been looking all over to solve this problem before I actually broke down and decided to finally ask for my psecific problem. I am using ClickOnce installation and when I use the setup.exe to install nothing runs, not even on my personal computer that I know has all of the proper libraries and such. I'm not sure what I am doing wrong so it is difficult to explain the problem.
I have included dotNetFramework4.0 client x86 x64 , xna redistributable 4.0 and windows installer 3.1 along with my game and I have it set to install all of that with setup , also I have it set to download prereqs from same location as application. I've tried it on three separate computers , one that does not have XNA or VS C# installed and the same problem occurs.
Here is the problem , after I install the game nothing runs, I try clicking on the ClickOnce application file (the one with my game's icon image) and again nothing happens. The thing that really bugs me is that there isn't any errors or crashes or anything , it's almost like clicking on the desktop screen. (I looked at the properties of the "shortcut" that was installed with the game and the file size of the shortcut is like 300 bytes. Isn't that really small? I was thinking maybe there is a problem with a startup executable? I'm not sure though.)
I've tried tweaking some stuff in the Publish section of my project , such as un-checking the box that says "use .deploy extension files" (I don't know why, I've been grasping at straws here) I've been looking into some other installers such as NSIS but I don't know how to compile a list of files to include in other installers and I feel like that won't solve the problem anyway because I've gotten ClickOnce to work with me before.
On one computer there was an error report that said something about 'deployment and application do not have matching security zones.'
Game.application resulted in exception. Following failure messages were detected:
+ Deployment and application do not have matching security zones.
It's getting late so if I need to provide more information let me know.
ClickOnce can be a fickle thing. There are times that I've had errors occur that could only be solved by recreating an entire Windows user profile. Because there are so many different options for ClickOnce, it's going to be hard for me to diagnose your exact issue, so I can only offer what options I used to successfully install via ClickOnce.
Publishing Folder: local folder
Installation Folder URL: blank
Install Mode: offline
Application Files
Make sure the Publish Status of your game files is set to Include (Auto)
Make sure the Publish Status of the XNA libraries is set to Prerequisite (Auto)
Click Prerequisites
Microsoft .NET Framework 4 Client Profile
Microsoft XNA Framework Redistributable 4.0
Windows Installer 3.1
Do not check for updates
Everything else default under Options (publisher/suite name shouldn't affect anything)
Specify the version number
Publish Now
Install the game through the setup.exe provided in the publish location. I always distribute every file that is publishes. However, you can clean up old versions in the "Application Files" folder if you don't want the history to be distributed.
You can double check the "Application Files" folder to see if your version got published correctly (look at the files that were deployed and see if they match your project contents).

Resources