Xamarin: The previewer requires a 64bit version of Java


If you are getting “The previewer requires a 64bit version of Java” when running the Xamarin Form Previewer, you need to download the 64bit version of the JDK not the JRE.

Once downloaded and installed, go to ToolsàOptionsàXamarin

Point the JDK to the 64bit version

Categories: Xamarin Tags:

Debug Aspnet Core HTTP Error 502.5 – Process Failure


Today after upgrading an aspnet core 1.0 to 1.1 I was getting HTTP Error 502.5 – Process Failure

In your project web.config:

  • Enable stdoutLogEnabled (set it to true)
  • Set full path for stdoutLogFile and make sure that the “logs” folder already exists
  • Then hit F5

<aspNetCore
processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="true"
stdoutLogFile="C:\logs\stdout"
forwardWindowsAuthToken="false"/>

In my stdout file I got the following error:

The specified framework ‘Microsoft.NETCore.App’, version ‘1.1.0’ was not found.

– Check application dependencies and target a framework version installed at:

C:\Program Files\dotnet\shared\Microsoft.NETCore.App

– The following versions are installed:

1.0.0-rc2-3002702

1.0.1

1.0.3

– Alternatively, install the framework version ‘1.1.0’.

I was under the impression that I had already installed version 1.1.0. But it seems that I installed 1.0.3 instead J It was 1:00 AM LOL

Here is the trick part. When you go to https://www.microsoft.com/net/download/core to download .NET Core, the default selected tab is LTS instead of Current

Select Current and download the latest version of .NET Core SDK

 

Categories: asp.net Tags: ,

Use JQuery to get data from specific html table column


One of the gigs I am currently working on is to load test a web application. I needed some ids to feed my load test scripts but I didn’t have access to the database. I can view the information on a grid on one of the HTML pages. I solved the problem by using JQuery to query the HTML table and extract the ids I need. The id column is the second column on the grid and hence I am using eq(1) in the script below.

Click F12 to open the dev tools and I excuted the following scripts to get the ids  I needed.

$(‘table > tbody > tr’).each(function(i) {

console.log( $(this).find(‘td:eq(1)’).text())

});

Categories: javaScript, Uncategorized Tags: ,

Install TFS 2015 Build Agent on Premises


In the previous article, I showed how to install and configure Maven on the TFS Build server to build Java applications. This article however applies to either Java or .NET applications. This article is based on the version 1 of Build Agent TFS 2017 has a new build agent that I will blog about in the future.

Download the Build Agent

  • Go to http://<tfsUrl&gt;:8080/tfs/_admin
  • Click on the Agent pools tab
  • Click on Download agent
  • Extract the contents of the zip file to c:\Agents\1

Configure Build Agent as a Service (without executing UI Testing)

TFS Build Agents can run as a service or a user. From my experience, most build agents run as a service. You need to run as a user or interactively, when you have a build that performs UI testing such as Selenium or CodedUI.

  • Open command line
  • C:\Agents\1\ConfigureAgent.cmd


  • I have used the default options. When you enter the tfs url, make sure you add /tfs at the end of the url
  • The default user account is Network Service. You can use domain user account if you need to control the permissions

Configure Build Agent in Interactive mode (to Run Selenium or other UI Tests)

In this case, we need to configure the build agent to run interactively (i.e. answer to install ‘N’ it as a service). I also created a new Pool and called it Interactive to group all the agents that run in interactive mode.

  • Open command line
  • Extract the agent into C:\Agents\2
  • C:\Agents\2\ConfigureAgent.cmd


  • As mentioned above, I am using the new pool which is called Interactive and the agent is not running as a service.
  • When you enter the tfs url, make sure you add /tfs at the end of the url

View Agents on the Web Portal

  • Go to http://<tfsurl&gt;:8080/tfs/_admin/_AgentPool
  • Agents colour coded in green means that that they are online and connected to TFS. Otherwise, they will show in red
  • From this screen you can also disable or delete an agent



Categories: TFS2015, Uncategorized Tags: , ,

Configure a TFS 2015 Build Server for Java


Introduction

TFS 2015 comes with a new build engine. It supports building many programming languages such as .NET, Java, Xcode, Android and other languages. You can even have a build agent on Linux. For more information visit https://msdn.microsoft.com/en-us/Library/vs/alm/Build/feature-overview

In this document, I will show how to configure a build server to run Java Maven builds.

Installing maven

System Requirements (Copied from Maven website)

  • Java Development Kit (JDK) Maven 3.3 requires JDK 1.7 or above to execute – it still allows you to build against 1.3 and other JDK versions by Using Toolchains
  • Memory No minimum requirement
  • Disk Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB.
  • Operating System No minimum requirement. Start up scripts are included as shell scripts and Windows batch files.

Installing Java

Make sure you install the JDK and not just the JRE. Other than that, the installation itself should be straightforward

Create the Environment Variable JAVA_HOME

  • Go to Control panel –> System and Security –> System –>Advanced system settings –> Advanced –> Environment Variables
  • Add new System variable and enter JAVA_HOME as “the Variable name” and jdk path


  • Restart the machine
  • To test, open commandline and type echo %JAVA_HOME%

Download Maven

At the time of writing this document, Maven 3.3.9 was the latest version of Maven. Download Binary zip archive from http://maven.apache.org/download.cgi. I created a folder at c:\JavaTools to have my Java related tools. I extracted the contents of the zip file into c:\JavaTools folder


Test Maven from commandline by typing c:\JavaTools\apache-maven-3.3.9\bin\mvn -v . If you have all the prerequisites, you should see something similar to the following output

c:\JavaTools\apache-maven-3.3.9\bin\mvn -v

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)

Maven home: c:\JavaTools\apache-maven-3.3.9\bin\..

Java version: 1.8.0_72, vendor: Oracle Corporation

Java home: C:\Program Files\Java\jdk1.8.0_72\jre

Default locale: en_US, platform encoding: Cp1252

OS name: “windows server 2008 r2”, version: “6.1”, arch: “amd64”, family: “dos”

Create an M2_HOME Environment Variable

  • Create M2_HOME system variable with a value of the Maven folder


  • Restart the machine logout and log back in

What’s Next

In the next blog post, I will show how to install and configure Team Build agents in TFs 2015.

Categories: TFS2015, Uncategorized Tags: ,

Use PowerShell to call TFS 2015 REST API’s


Few months ago, I was helping a client upgrading from TFS 2010 to 2015. After the upgrade, we were getting a message that says “This feature cannot be used until you configure it for this team project”.

Long story short, I had to upgrade the process template for over 77 team projects. Luckily they were all created using the Agile template 🙂 The process involves running some commands for the collection and others for each team project. That’s when I decided to script it with PowerShell.

In this post, I will show how to use Powershell to call the TFS 2015 REST API. Let me know in the comment section if you are interested in the script to upgrade the process template.

Show me the code

I am using the “Get list of team project” API which is listed at https://www.visualstudio.com/en-us/docs/integrate/api/tfs/projects


$tfsUrl = 'http://tfsUrl:8080/tfs/'
$collectionName = 'DefaultCollection'
$collectionUrl =  "$($tfsUrl)$($collectionName)"
# Construct the Get list of team projects url
$getProjectsUrl = "$($collectionUrl)/_apis/projects/?api-version=1.0"

# Call the REST API using Invoke-RestMethod. -UseDefaultCredentials for using windows authentication
$json = Invoke-RestMethod -UseDefaultCredentials -uri $getProjectsUrl
$formatedJson =  $json | Format-List
Write-Output $formatedJson

The value field contains the data we need. It is just a matter of extracting the project names from the value field

$tpNames = $json.value | select name
Write-Output $tpNames

The above snippet only shows you a list of project names on the screen. Lets do something more interesting. Let’s say we want create a new team for each team project in a collection and call it Database Team

# Create team API
$createTeamUrl = "$($collectionUrl)/_apis/projects/{0}/teams?api-version=2.2"
#Json that contains the data to be POSTed
$Body = @{
            name = "Database"
            description = "Database Team"
        }

# for each team project, create a team called Database by doing a post request to the create team api
$json.value.ForEach({
    Invoke-RestMethod -Method Post -UseDefaultCredentials -uri ($createTeamUrl -f $_.name) -Body (ConvertTo-Json $Body) -ContentType "application/json"
})

Conclusion

It is really convent and powerful to use Powershell or any other scripting language to TFS’s REST API. To learn more about TFS’s REST APIs visit https://www.visualstudio.com/en-us/docs/integrate/api/overview

Fix TFS 2015 Build’s Queue is Empty


Today I wasn’t able to select a queue while creating a build definition or queuing a build using the new build engine that comes with TFS 2015. The drop down was blank.

This problem may occur if you don’t have build queues for your Collection or if you don’t have permission to use the queues in your build definition.

Go to the administration site for your collection

Check if you have queues for Collection

If you do, select your queueà Role à Agent Queue Users à Double click on Agent Queue Users à add users or groups

Otherwise click the “New queue” link to create a new queue