Building web applications broken after uninstalling VS2013

I ‘m no longer using VS2013, so i decided to uninstall it. I’ve been using VS2015 for more than a year now, so it made sense to clean up my workstation.

After uninstalling, I got the following error when building web applications with MSBuild:

error MSB4019: The imported project «C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\WebApplications\Microsoft.WebApplication.targets» was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

I decided to use a new feature in Powershell 5 to solve this: Symbolic links. This has actually been available in NTFS for many years, but the powershell support is new:

PS> cd C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio
PS> New-Item -ItemType SymbolicLink -Name v11.0 -Target .\v14.0\

This creates a symbolic link that makes the v11.0 folder point to the v14.0 folder:

Which gives me what I want:
Build succeeded.

Creating RavenDB-databases from a script

I’m working on setting up all servers from scripts, and tried to explicitly create a RavenDB database from a script. RavenDB will automatically create databases for you, but since the Replication bundle must be added when the database is created, I need to explicitly create databases.

The RavenDB documentation states that you can create a database just by inserting a document, but there is no example on how to do that.

I manually created a database and copied out the document that was inserted in the database:

      "Raven/DataDir": "~\\Databases\\Fido",
      "Raven/ActiveBundles": "PeriodicBackup;Replication"

The documentation does not specify the url that you should PUT the document to, so I had to use Fiddler to trace the database creation. The url of the database document should be:


I have a PowerShell function that wraps System.Net.WebClient to do HTTP requests, but you can use curl or wget if you prefer.

Execute-HTTPPutCommand "http://localhost:8080/docs/Raven/Databases/Fido" "{ 'Settings': { 'Raven/DataDir': '~\\Databases\\Fido', 'Raven/ActiveBundles': 'PeriodicBackup;Replication'  }}"

Simulating remote web services for testing

I recently had to troubleshoot an error in an integration with a 3rd party system. We were fetching changesets over a web service, and somehow ended up with errors in the database.

The error rate was just a few errors for every 1000 elements, so this required quite a bit of effort to figure out, because the conversion logic was quite complex. The code was tested, this was obviously a scenario that wasn’t covered by the tests.

I had to run through the code quite a few times to isolate the error in the application logic,  and I didn’t want to do the request from the source several times while I figured it out. Also, I wanted to reproduce the error on my own computer so that I could use all the tools I wanted.

First of all I got hold of the message I recieved as plain XML. This can be done in a number of ways, I had the luxury of being able to set up an extra Send Port in BizTalk that also wrote the message to a file. If you don’t have that luxury, you can use WCF Message Tracing [] or you can write a request and serialize the response object to xml.

Since I had the Message as XML, my challenge was how to be able to request this without connecting to the actual web service. If I could simulate the service, I could test the integration without changing my application, and that would make me more confident that I was testing the right thing. I decided to try to simulate the  web service locally with Nancy. If you don’t know Nancy (, it is a lightweight web application framework that can be set up to listen to http request and return any content you want it to. The most basic Nancy application looks like this:

public class MainModule : Nancy.NancyModule
    public MainModule()
         Get["/"] = x => "Hello, world!";

This is what I did:

First, I created a console application to host my simulated web service. Then I got the Nancy framework, and the Nancy self hosting host (There are host options for ASP.NET and WCF) from Nuget:

install-package nancy


This small program can serve the message XML on a HTTP POST

  class Program
        static void Main(string[] args)
            var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri(""));

    public class MainModule : Nancy.NancyModule
        public MainModule()

            Get["/"] = x => "Hello, world!";
            Get["/MessageService"] = ReturnStations;
            Post["/MessageService"] = ReturnStations;

        private dynamic ReturnStations(dynamic o)
            return Response.FromStream(File.OpenRead("message.xml"), "text/xml").WithStatusCode(HttpStatusCode.OK);

By wiring the request to both the Get and Post, I could verify the setup in the browser.

To trick my computer into sending the service request to itself, I added this line to my hosts file:

I still had one last thing to fix before I could start: When I ran the program I got an HttpListenerException: Access Denied:

This is because port 80 is reserved, and only administrators can listen to that port. This can be fixed in two ways: Either run the application as administrator (which I try to avoid, having experienced CodeRed, Nimbda and SqlSlammer) or I can grant myself access to listen to port 80 using this command:

netsh http add urlacl url= /user=Per-Frode

Now I was ready to start testing. This 5 minute setup gave me much quicker and better feedback, and made sure that I could look for errors without affecting the remote system.

One final note:

If your XML does not contain the SOAP envelope, you will get an exception from WCF:

[System.ServiceModel.CommunicationException]: {«Unrecognized message version.»}

Just wrap the Message in a SOAP envelope to fix this:

<?xml version="1.0" encoding="UTF-8" ?>
xmlns:SOAP-ENV="<a href=""></a>"
xmlns:xsi="<a href=""></a>"
xmlns:xsd="<a href=""></a>">
      ... Insert Your Message here

Error with git tfs because of case differences in pathname

I had a strange case where two files was commited to TFS, and then the folder of these files were renamed to the same name with differing case before more files were added to the folder. This leads to the unfortunate situation where git cannot track some of the files in the folder, since git is case sensitive while TFS isn’t.

C:\source\Project>git tfs pull 
C2511 = ce456058982e4b8e936b350f8900eb077ca9a300 
Updating fcdeaf9..ce45605 Fast-forward
.../Scripts/jquery/datepick/jquery.datepick-en.js | 3 ++- 
.../Scripts/jquery/datepick/jquery.datepick-no.js | 3 ++- 
.../Scripts/jquery/datepick/jquery.datepick.js | 3 ++- 
3 files changed, 6 insertions(+), 3 deletions(-) 
C:\source\Oti>git status 
# On branch master 
# Untracked files: 
# (use "git add <file>..." to include in what will be committed) 
# app/Project.Web/Scripts/jquery/datePick/jquery.datepick-en.js 
# app/Project.Web/Scripts/jquery/datePick/jquery.datepick-no.js 
# app/Project.Web/Scripts/jquery/datePick/jquery.datepick.js 
nothing added to commit but untracked files present (use "git add" to track)

The easy workaround was just to rename the folder in TFS, and then do a new git tfs pull, but it took me quite some time to figure this one out.

Bringing my git-ignore settings with me

Since I’m working a lot of different places, and on quite a few different computers, I need to reconfigure my git-ignore settings every now and then. To manage my settings, I’ve put my git excludes in my Dropbox folder. This gives med the added advantage that all ignore settings are automatically syncronized between computers.

This is the file I have in Dropbox:


And this is how git status looks like if I don’t use the ingore file:

Git notifies me that the Visual Studio build output and local settings are in the repository but are untracked. As my solutions grow, this list can grow to be very big.

I run this statement in git bash, pointing to my dropbox folder on my D: drive. This should work from Windows Command Line too, but then you need to use the Windows path

git config --global core.excludesfile /d/Dropbox/git/excludes

Note that it’s important to use the –global flag to make it valid for all local repositories, as this makes the command store the setting in the .gitconfig in your HOME folder.
When I now run git status, all the local files and settings from Visual Studio is now ignored:


Warning: this may seem like advertising!

I’ve been hooked on Google+. Probably somewhat because of my geeky nature, but I love how often sharing on G+ turns into conversations. I also love the photo sharing functions with great image viewing functions and image details. Look at this example album:, and remember to click on Actions -> Details under the picture so you can see both the map of the location and the camera details.

I also like how easy I can share things from my phone. The fact that Google+ uses Picasa for picture sharing is an extra plus, I’ve used it for years and would never put an image on Facebook because of their shady privacy policy.

I believe that the worst hype is over, but if you still haven’t gotten an inviation, here is one for you:

An adventure in XCode and Cocoa

Since I haven’t learned a new language in a while, I wanted to try something new. Next stop Cocoa Mac and XCode.

It took quite a while to figure out how the Interface Builder and XCode worked together, but I’ll try to give a quick explanation:
First I created a new Application, and XCode created a XIB-file for me. This was called MainMenu.xib and contained both a system menu and a view. The XIB could be opened in Interface Builder, and I could draw the UI.

I then created a Cocoa class that inherited from NSView. In this class I implemented my properties and methods, which is called Outlets and Actions. Using the correct types is important for the Interface Builder to work when connecting code and UI together.

#import <Cocoa/Cocoa.h>
@interface HelloWorldView : NSView {
	IBOutlet NSTextField *words;
- (IBAction)sayHello:(id)sender;


#import "HelloWorldView.h"
@implementation HelloWorldView
- (IBAction) sayHello:(id) sender{
	[words setStringValue:@"Hello, world"];
	[words setNeedsDisplay:YES];


Then I hooked this class up to the View using Interface Builder.

Finally I hooked the text fields to the properties and the Buttons to the methods.
IB Bindings
Then I ended up with a working Cocoa mac app

Følg meg

Få nye innlegg levert til din innboks.

Bli med 373 andre følgere