BM-Bloggers

The blogs of Black Marble staff

NDC London 2016 (Post 1 thanks)

 

I had a great time at NDC 2016. It was a very well organised event, everybody enjoyed the event, content and the food.

Huge thanks to the great and efficient organisation by the NDC team.

Also thanks to the great people with clearly great taste who attended my talk.

I am separating the post into a few areas so I can keep updating them without people having to read long lists and work out what has changed.

 

b.

 

 

Fixing cannot load dashboard issues on BlogEngine.NET using sub blog aggregation

As I discovered during my BlogEngine upgrade, there is an effort within the project team to focus the codebase on three possible usage models on any given BlogEngine server instance:

  • Single blog with a user – a personal blog (default)
  • Single blog with many users – a team/company blog
  • Many blogs each with a single user – a set of related blogs that can be agregated togther

I needed the third option, problem was in its history our blog has been both of the other two types, so I have multiple user accounts for each blogs, and login usernames are repeated between individual blogs on the server.

This is not fundamentally an issue for a server running in the third mode, except on the primary blog that is setup to provide agregation of all the other blogs.  Even here, on a day to day basis, it is not an issue either, basic post RSS aggregation is fine. However, when you login as an administration user and try to access the dashboard you get the error

Item has already been added. Key in dictionary: 'displayname' Key being added: 'displayname'

The workaround I have used in the past was to temporarily switch off blog aggregation whenever I needed to access the primary blog dashboard – not the best solution.

After a bit of investigation of the codebase I found that this issue is due to the fact we had users  called ‘admin’ on the primary and all the child blogs. The fix I used was a bit of SQL to do some user renaming from ‘admin’ to ‘adminblogname’ . I needed to rename the username in a few tables.

AS USUAL BEWARE THIS SQL, MAKE SURE YOU HAVE A BACKUP BEFORE YOU USE IT, IT WORKS FOR ME BUT I MIGHT HAVE MISSED SOMETHING YOU NEED


update p
set p.SettingValue = concat (p.SettingValue , ' ', b.BlogName)
from be_Profiles p
    inner join be_Blogs b on
        b.BlogID = p.BlogId
where
SettingName ='displayname' and
SettingValue = 'admin';

update p
set p.UserName = concat (p.UserName , b.BlogName)
from be_Profiles p
    inner join be_Blogs b on
        b.BlogID = p.BlogId
where
username= 'admin';

update u
set u.UserName = concat (u.UserName , b.BlogName)
from be_Users u
    inner join be_Blogs b on
        b.BlogID = u.BlogId
where
username = 'admin';

update r
set r.UserName = concat (r.UserName , b.BlogName)
from be_UserRoles r
    inner join be_Blogs b on
        b.BlogID = r.BlogId
where
username = 'admin';

 

This is not a problem specific to admin users, any username duplication will cause the same error. This basic SQL script can be modified to fix any other user accounts you might have username clashes on.

Once this SQL was run I was able to login to the dashboard on the primary blog as expected.

Upgraded to BlogEngine.NET 3.2

I have just completed the upgrade of this blog server to the new release 3.2 of BlogEngine.NET. I did a manual upgrade (as opposed to the automated built in upgrade) as I needed to make a few changes from the default settings. The process I used followed the upgrade process document

  1. Downloaded the latest release and unzip the folder
  2. Run the SQL upgrade script (in /setup/sqlserver folder), this adds some new DB constraints
  3. Created a IIS web site using the new release
  4. Copied in the sample web.config from the /setup/sqlserver folder.
  5. Copied in my App_DATA folder
  6. Accessed my site

As I had not copied anything from the old custom folder, I had theme issues at this point. However, I decided to moved all the blogs to the newest generation of theme templates, so did a quick fix up by hand on each one, picking the required theme and making sure any settings, like Twitter accounts, were set (note these are set on a per blog/per theme basis, so changing a theme means you need to reenter any custom values). I also needed to copy in a few missing logos and any extra widgets from my old custom folder the blogs were using.

Once this was all done I had an upgraded blog server.

Running CodeUI tests on a VM with on remote desktop session open as part of a vNext build

If you want to run CodeUI tests as part of a build you need to make sure the device running the test has access to the UI, for remote VMs this means having a logged in session open and the build/test agent running interactivally. Problem is what happens when you disconnect the session. UNless you manage it you will get the error

Automation engine is unable to playback the test because it is not able to interact with the desktop. This could happen if the computer running the test is locked or it’s remote session window is minimized

In the past I would use a standard TFS Lab Management Environment to manage this,you just check a box to say the VM/PC is running coded UI tests and it sorts out the rest. However, with the advent of vNext build and the move away from Lab Manager this seems overly complex.

It is not a perfect solution but this works

  1. Make sure the VM autologs in and starts your build/test agents in interactive mode (I used SysInternal AutoLogin to set this up)
  2. I connect to the session and make sure all is OK, but I then disconnect redirecting the session
    • To get my session ID, at the command prompt, I use the command query user
    • I then redirect the session tscon.exe RDP-Tcp#99 /dest:console, where RDP-Tcp#99 is my session ID
  3. Once I was disconnected my CodeUI test still run

I am sure I can get a slicker way to do this, but it does fix the immediate issue

Updated:

This bit of Powershell code could be put in a shortcut on the desktop to do the job, you will want to run the script as administrator

$OutputVariable = (query user) | Out-String

$session = $OutputVariable.Substring($OutputVariable.IndexOf("rdp-tcp#")).Split(" ")[0]

& tscon.exe $session /dest:console

Live Writer becomes Open Live Writer

My primary blog editor has been Microsoft Live Writer for years, but it has always been a pain to install via Windows Essentials (as I don’t want the rest of the product), also I was never able to find the right version when I rebuilt a PC. This was not helped by the fact there has been no development of the product for years, so I struggled to remember what year version I really needed (last one was 2012 by the way).

So it is great news that the code base has gone Open Source at  http://openlivewriter.org/, and this is my first post using the new editor. Seem to work great.

Nuget restore fails to restore all the files on VSTS build if using project.json files

We are currently working on updating a Windows 8 application to be a Windows 10 Universal application. This has caused a few problem on a TFS vNext automated build box. The revised solution builds fine of the developers box and fine on the build VM if opened in Visual Studio, but fails if built via the VSTS vNext build CI MSBuild process showing loads of references missing.

Turns out the issue was due to Nuget versions.

The problem was that as part of the upgrade the solution had gained some new projects. These used the new project.json file to manage their Nuget references, as opposed to the old packages.config file. Visual Studio 2015 handles these OK, hence the build always working in the IDE, but you need Nuget.exe 3.0 or later for it to handle the new format. The version of Nuget installed as part of my vNext build agent was 2.8. So no wonder it had a problem.

To test my assumptions I added a Nuget Installer task to my build and set an explicit path to the newest version of Nuget.

image

Once this was done my build was fine.

So my solution options are

  1. Don’t use the agents shipped with TFS 2015, get newer ones fro VSTS this has a current version of Nuget (just make sure your agent/server combination is supported. I have had issues with the latest VSTS agent and a TFS 2015 RTM instance)
  2. Manually replace the version of Nuget.exe in my build agent tools folder – easy to forget you did but works
  3. Place a copy of the version of Nuget.exe I want on each build VM and reference it s path explicitly (as I did to diagnose the problem)

The first option is the best choice as it is always a good plan to keep build agents up to date

An out-the-box way to let local Hyper-V VMs see the Internet without using a DD-WRT router

Updated 10 Aug 2016 - Revised for Win10 anniversary build 1607

I have posted in the past about using a DD-WRT virtual router to bridge between local VMs on my development PC and the outside world

 

 

With the recent changes in HyperV on Windows 10 and Server 2016 we have an alternative as discussed by Thomas Maurer in his post (pre Win10 anniversary build 1607) or this post (post Win10 anniversary build 1607). You can use a NATSwitch, thus removing the need for router VM. This does however raise different issues, that of address assignment, the router was also a DHCP server. However, it does mean I don’t have to mess around with manually setting external IP addresses for the router each time I join a different WIFI network. So on the whole I think iti is a better solution.

My new setup is as follows.

image

 

  • Using Powershell, create the NATSwitch as per Thomas Maurer’s post.
  • On each guest VM set a fixed IP address e.g. 172.92.91.2, with a default route of the NATSwitch’s port on the host OS i.e. 172.92.91.1 and a publicly accessible DNS such as a Google’s 8.8.8.8. Once setup it should be possible to access the internet from the guest VM
  • To access each guest VM from the host OS you can just use it’s IP address e.g. 172.92.91.2, this works because the host OS has a connection on the same NATSwitch network, 172.92.91.1. It makes sense to add a hosts files entry on the Windows 10 PC so that the user has a friendly name to access each guest VM e.g.

                    172.91.92.2        typhoontfs

Once this is all done you seem to have a workable system, only time will tell how it works in practice.

First experience of a Band 2

I have been using a Band 2 for a couple of weeks now as opposed to my original Band. The major thing I have noticed is I don't notice it on my wrist. It feels just like a watch.

The old one, though not too bad did feel a bit lumpy, banging on the wrist. So that is an improvement, also it looks less like I am a prisoner with a tracker on day release. The Band 2 looks like a designer was more involved as opposed to just engineers.

But how does it compare to my issues with the original Band?

  • Is it now waterproof? - No, still can't swim with it.
  • How about battery life? - Seems a bit better, on a day to day use I am charging it roughly every couple of two days as opposed to each day. I have not tried a long cycle ride yet, so it remains to be seen if I get more than about 5 hours of full data capture. I would expect a bit better, but not a huge gain
  • Does the touch screen work when it is raining or my fingers wet? - Does seem better

So all positive thus far