Only use https to access teamcity server

Read this blog before you do my steps:

If the steps in the article didn’t help you, then try with my solution 🙂

1. In the connector, only use port 443 as a connector, this mean, you have to remote the connector for port 80


2. In IIS -> Default Website (port 80), change “http redirect” to your https


Add in the internal dns (otherwise, you need to add it in the host file

It is pointing to the internal ip of machinename:

Change the internal dns to point to the external ip of the server

The certificate above has expired, and we have to replace it with new one. Follow this guide to solve it:

Some highlights:

In C:/Teamcity/conf/server.xml


In C:/Teamcity/conf/web.xml


Remember to open firewall port for 443.

Trigger teamcity run using javascript

Read the following code:

function connectingToSP() {
(function () {
var cors_api_host = ‘’;
var cors_api_url = ‘https://’ + cors_api_host + ‘/’;
var slice = [].slice;
var origin = window.location.protocol + ‘//’ +;
var open =; = function () {
var args =;
var targetOrigin = /^https?:\/\/([^\/]+)/i.exec(args[1]);
if (targetOrigin && targetOrigin[0].toLowerCase() !== origin &&
targetOrigin[1] !== cors_api_host) {
args[1] = cors_api_url + args[1];
return open.apply(this, args);

var spURL = “https://yourteamcityhere/httpAuth/app/rest/builds”;

function getWWWAuthentication() {
var dfd = $.Deferred();

url: spURL,
beforeSend: function(xhr) {
xhr.setRequestHeader(“Authorization”, “Basic ” + btoa(“username:password”));
type: ‘GET’,
dataType: ‘json’,
contentType: ‘application/json’,
processData: false,
success: function (data) {
error: function(){

return dfd.promise();



Config TeamCity to run UI Test on NUnit Framework

For Agent machine

  1. Install Firefox
  2. Install NUnit Adapter on Visual Studio
  3. Add Firefox path to PATH

For coding


For Teamcity

1. Specific agent machine for compatibility2

2. In Artifact paths of General Settings: Copy everything from Release folder to another folder (optional)3

3. Define steps

3.1 Restore packages4

3.2 Build and Package Test solution5.PNG

/p:Configuration=Release /p:Platform=”Any CPU” /p:FrameworkPathOverride=”C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1″ /p:DeployOnBuild=true;PublishProfile=PackageToZip

3.3 Update Test parameters6.PNG

echo Username::%Test.Username% >\Test\UnitTest.CodeBase\bin\Release\Parameters.txt
echo Password::%Test.Password% >>\Test\UnitTest.CodeBase\bin\Release\Parameters.txt
echo SiteUrl::%Test.SiteUrl% >>\Test\UnitTest.CodeBase\bin\Release\Parameters.txt

3.4 Run UI Test in command line

Old\OmniaTest\UnitTest.CodeBase\bin\Release\TestWindow\vsTest.console.exe “\OmniaTest\UnitTest.CodeBase\bin\Release\UnitTest.CodeBase.dll” /UseVsixExtensions:true


Turn on read/write  permission for current user on: E:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow

vsTest.console.exe %~dp0/UnitTest.CodeBase.dll /TestAdapterPath:”your packages path\Test\Dev\packages”


4. Define Parameters7

5. Turn on console mode in the build agent

cs stop TCBuildAgent
ping -n 1 -w 10000 > nul

C:\BuildAgent\bin\agent.bat start