0 Comments

Some time ago I have shown how to configure automatic build of SSIS projects (SQL Server Integration Services). Unfortunately they require full version of Visual Studio installed on a build machine as it’s an overwhelming plugin (not only a toolset), what potentially could hit me back.

And well, of course it failed and hit me after 30 days! Turned out Visual Studio 2017 Community Edition expired and was refusing to cooperate more, producing this nice error log:


[12:08:30][Step 2/3] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script7138984668293949066.cmd
[12:08:30][Step 2/3] in directory: C:\TeamCity\buildAgent\work\2906b7d01f979ef5
[12:08:51][Step 2/3] 
[12:08:51][Step 2/3] Microsoft Visual Studio 2017 Version 15.0.27428.2027.
[12:08:51][Step 2/3] Copyright (C) Microsoft Corp. All rights reserved.
[12:08:51][Step 2/3] 
[12:08:51][Step 2/3] The license for Visual Studio has expired.
[12:08:51][Step 2/3] 
[12:08:52][Step 2/3] The evaluation period for this product has ended.
[12:08:52][Step 2/3] Process exited with code 1


Nothing simpler, I run Visual Studio and entered my credentials, that created a proper license etc. All the warnings on UI were gone. All was supposed to go back to normal, but somehow the same log appeared again.

Till now, it was actually my naïve thinking, as Visual Studio was launched in a context of a totally different user than the one used when I double-clicked the shortcut icon. Build system operated as the local system account, since it was the “TeamCity Build Agent” service that was configured to start it.

I tried to use RunAs plugin for TeamCity. I installed it, created dedicated BuildTool user, even configured in “Build Features” section of the build configuration. Of course I run Visual Studio as this user and entered obtained again the license. But automatic build process was still failing with this log:

[13:12:58][Step 1/3] MSBuild output
[13:12:58][MSBuild output] Access is denied.
[13:12:58][MSBuild output] The current directory is invalid.

I should have probably focused more on this message and grant read/write access for new user to the buildAgent folder (as this is the place, where the sources gets populated and processed) and that would be probably the final solution (even mentioned here). But since I am hot-tempered, I moved to another try.

Next, I reconfigured the whole TeamCity Build Agent service to start as BuildTool user. I added proper login permissions (to allow it to boot the machine, login as a service etc., more here), along with access to mentioned above folder.

TeamCity Build Agent service log-on properties

Since now on, I had no issue anymore and all builds successfully again.


Congrats!

1 Comments

Some time ago I read a post from Jakub Jędryszek about using a boogie board to make notes. The theory behind it was good enough to convince me to buy one from Gearbest.com. And to be honest I also recommend this toy after such a short period of time. The quality of sketches is amazing for daily tasks for such a low price! Although when I gave it to my kids I wish there was a button (second one) to preserve it and save somewhere as a bitmap image.

Anyway… where is my real problem here?

Well, till that day everything I ordered from Gearbest.com I did using a regular mail. I knew the delivery wasn’t the quickest in the world, but at least it was always predictable. And at the end, if not delivered directly too me, I could pick it up from my local post-office after being notified with aviso.

For that particular order I left the default method – i.e. DPD(UK) carrier service without further thinking. It was really express delivery I must admit. So quick that I almost missed it. Why? Because it’s my fault of course. So please, not treat my further description as a complain. I wish rather to explain, what were my mistakes and where to obtain information they will ask you if you start talking.

The story context is - from Gearbest.com I received a parcel number and I was supposed to use another website (17track.net) to keep tracking of the parcel’s status. What I did, simply checking once per few days, not every hour as I expected it to take at least a month. Then after two weeks, I got a call from an unknown number in the middle of my working hours and the same number tried once again on the next day. That’s it. No email, no info, no SMS about anything, no aviso. Even the status on 17track.net was not updated at that time. I didn’t even expect those calls to be related with my order as there are lots of maniacs in Poland that once you establish a company (be even self-employed) and make your phone number public, they constantly call you trying to sell almost anything, especially a loan.

Then I have seen the “failed” status on 17track.net and called back to be sure. And I was assured, my parcel ended up in a warehouse. Now I could only contact with support (PL phone: 225775555) for help. And here is the crisis: Gearbest provided me 10-digits-long parcel number, while the impatient girl on the other end of the line couldn’t do anything for me without 14-digits-long number. She insisted I should contact the seller first to get the valid number and then contact her again. It changed nothing, when I said, the package was supposed to come from China via DPD(UK). She couldn’t search via name, my phone number nor destination address. Madness!

How could I get the extended number? I didn’t see myself calling Gearbest support and even though, I have seen them saying the number was correct. I could have seen the correct status on the website they provided!

Just by pure accident I opened the www.dpd.co.uk website (not the www.dpd.uk) and entered the short tracking number. What’s even more scary – both sites look exactly the same, but the other website was not giving any results (identically as its polish counterpart www.dpd.com.pl) while the first one produced something like this:

dpd.co.uk


And here I noticed the current status (now: delivered) and full parcel number. The number I got from Gearbest was simply prefixed with “1550” and that’s it. I called DPD(PL) again and this time they believed, this package was for me!


Really funny story! Thx.

0 Comments

Among all the features of ASP.NET framework, there is one I love the most:

moving parts of the configuration (i.e. Web.config) into separate files!

It’s just it, a little something, that makes life so much easier by:

  • less effort while working with GiT (conflicts are subtle and with better context, changing braches mostly let you move also your local changes, or reset parts of it)
  • quicker navigation, as they are files with my custom naming convention (via R# hit Ctrl+T and start typing the name using only first uppercase letters of the file to open it)
  • custom sections can also be put in an another file.


In my typical scenario, I move away sections responsible for:

  • database connection strings (as they change the most)
  • WCF service definitions (behaviors, bindings and services themselves) as they can occupy lots of space
  • and definition of my custom section of continuously evolving list of options (titanSection).


Sample web.config

As the picture above shows separation is achieved simply by using “configSource” attribute inside a section that is supposed to be outsourced. And that’s all – just name the file, create it and inside that file define directly the same section tag as from Web.config. But this time put there a real content.


For example the content of database connection-strings (named by me: Web.Connections.config, that is located next to Web.config), could look like that:

Separate file with database connection-strings


You can name the files whatever you like. However I highly encourage you to have a naming schema. Anything that starts with ‘Web’ and has an extension ‘.config’ would be probably sufficient and also be easy enough to remember, what is inside.


Final though on custom section. It might be placed in separate location in identical way. Only difference is that his kind of section should have a code-behind C# class inheriting from ConfigurationSection with all public properties marked with ConfigurationPropertyAttribute attribute (and inner tags define as separate classes inheriting from ConfigurationElement).

Once the class is completed, inside Web.config there should be a link defined between that class and a custom name of the section. Notice the “configSections” and a “section” entry on the picture above. It contains the name of the “titanSection” section and also points to a TitanConfigSection class (with an assembly name) that will handle accumulation of all settings.

Then only the imagination stops you from creating config complicated as the one below:

titanConfig


I hope it proved useful for you too!

0 Comments

It should be simple, it should be quick. And as usual it turned out to be hard, painful and forced me to install Visual Studio 2017 back on a build machine. I’ve cried a lot that hour. Now I am just waiting, what will fail next, once I see this comment in TC build logs, even though I logged-in and obtained permanent license.

[13:05:08][Step 3/3] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script5352870621326270693.cmd
[13:05:08][Step 3/3] in directory: C:\TeamCity\buildAgent\work\2906b7d01f979ef5

[13:05:12][Step 3/3]
[13:05:12][Step 3/3] Microsoft Visual Studio 2017 Version 15.0.27428.2027.
[13:05:12][Step 3/3] Copyright (C) Microsoft Corp. All rights reserved.
[13:05:12][Step 3/3]
[13:05:12][Step 3/3] The license for Visual Studio expires in 30 days.


Anyway, it makes me to loose even more hairs, due to the fact, that not so long ago I happily removed Visual Studio 2010 from it (check this post)! And simply Visual Studio 2017 build-tools were not enough for the SQL Server Data Tools (SSDT) installer including SQL Server Integration Services (SSIS). Somehow documentation stays, it should be possible to continue and that it will install minimal version of Visual Studio (Shell or something?), but at 85% it tried to apply some VSIX package, failed and roll backed everything.

What’s even worse, is that .dtproj project format is incompatible with MSBuild and it’s impossible to build it without essentially Visual Studio IDE (i.e. devenv.com, check here). Even if you wish to build it using VSTS Online/TFS you still need some tricks.

I hope I linked all stuff, that helped me to understand the subject. So let’s stop weeping and wailing and let’s get something done!


TL;DR


Prerequisites:

  1. Install Visual Studio 2017 Community
  2. Install SQL Server Data Tools (SSDT) (with checked option for SQL Server Integration Services)


Now in TeamCity:

  1. Create a build configuration (here named “Bazy Win32” on figures below)
  2. Add new parameter that points to the location of devenv.com of the Visual Studio

    TeamCity build parameters

    i.e.: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com

  3. Add a command-line build step, that will invoke Visual Studio and instruct it to build the solution

    TeamCity build step

    The command is:
    "%env.vs2017_devenv_path%"  <path_to_solution> /rebuild "Development"

    (variable is taken in quotation marks, since it contains spaces etc. as its value)

  4. Remember to put generated .ispac (from bin/Development folder) among other artifacts of the build configuration.
  5. DONE!

0 Comments

Recently, I have shown, how to enable Application Insights within own WCF server application (look here). It might similarly work in other kinds of apps, so we won’t bother with further demystification of this procedure. But as you might suspect (or already stepped on), you will quickly require more metadata transmitted than it is done by default.

My scenario is pretty simple. The WCF server is installed multiple times, in multiple physical locations across the whole country. And they all just sit there, working since most of the bugs aren’t so critical. It can’t be even updated everywhere at the same time. So how to actually distinguish between different instances and app versions in case of a crash or other serious misbehaviors?

And the answer is – ITelemetryInitializer.

This kind of objects are responsible for performing initialization of the telemetry data gathered and then sent back to the Azure’s AppInsights service.


Here is the recipe, how to define and enable one in own project:

1) First create a class that implements ITelemetryInitializer interface.

2) Within Initialize() method, set additional context properties. To match my scenario, let it be two fields:

  • ClientInstance” – to let know, which server it’s running on (yes, it should be read from external configuration file, but should be clear enough for now, as I hard-code it)
  • BuildInfo” – to inform about application version running there, which I read directly from the assembly name

Of course the way it was obtained should be updated to match the logic in your app.

public sealed class ClientInstanceTelemetryInitializer : ITelemetryInitializer
{
    private const string ClientInstanceParam = "ClientInstance";
    private const string BuildInfoParam = "BuildInfo";

    private readonly string _instance;
    private readonly string _version;

    public ClientInstanceTelemetryInitializer()
    {
        _instance = "beaa9ac0-3267-41e4-9c14-2167271aca4d"; // should be different for each running instance
        _version = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version;
    }

    /// <inheritdoc />
    void ITelemetryInitializer.Initialize(ITelemetry telemetry)
    {
        telemetry.Context.Properties[ClientInstanceParam] = _instance;
        telemetry.Context.Properties[BuildInfoParam] = _version;
    }
}

3) Finally, register the initializer via ApplicationInsights.config file (this file was added automatically to the project, when AppInsights NuGet packages were installed inside the previous guide). Simply add the type at the end of TelemetryInitializers section. It will be instantiated automatically at application startup.

Telemetry Initializers

And that was all again.


Verification:

Now, when navigating to the crash logs on Azure, open a request details, click ‘Show all’ properties and the view should look similar to this one:

Azure Telemetry Info

“Custom Data” section contains info about ClientIntance and BuildInfo as expected.


Thanks!