Tuesday, 18 August 2015

Creating a Team Project in TFS in Visual Studio 2015

To get to the New Team Project menu in Visual Studio 2015 you need to go to Team Explorer and click on the dropdown bar at the top.  Select 'Projects and My Teams' and you will see the 'New Team Project' menu item.


Note: You do need to have the 'Create new projects' permission on the TFS Application tier to do this.

Monday, 17 August 2015

The OutputPath property is not set for project '.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Release' Platform='Any CPU'

I am busy upgrading a large project originally built with Visual Studio 2008 and TSF2008.  We are upgrading to Visual Studio 2015 and TFS2013.  During this process I was getting the following error on TFS:
The OutputPath property is not set for project '<project>.csproj'.  Please check to make sure that you have specified a valid combination of Configuration and Platform for this project.  Configuration='Release'  Platform='Any CPU'
Notice the space between 'Any' and 'CPU' in the platform property.  In 2008 it seems like there was no space.  To fix this you have two options, change your project files to use 'Any CPU' or change your TFS build scripts to pass in 'AnyCPU'.

Thursday, 6 August 2015

Bug in SQL Server?

Found a little bug in SQL Server 2008. Maybe just a Management Studio bug, but still...

Restored a database from a server in another domain to my local instance of SQL Server.
Start running integration tests against the local copy and getting the following error:
Could not obtain information about Windows NT group/user  'domain2\Administrator' error code 0x5.
Some tests are passing, some not.  So I debug one that does not.  Turns out it is inserting records into a table with a trigger that inserts a record into an Audit table.

Nothing peculiar about that, have seen this pattern used in the wild, but never seen this error before.  I start looking at my local copy of the DB and first check the owner.  That is set to my login in the local domain 'domain3\MyUsername'.  Leave it alone for a while, have a look at the logins for the Database, No 'domain2\Administrator' to be found.  Try adding 'domain2\Administrator' as a user and get an error, user already exists.  WTF! I can't see this user anywhere.  Some serious head scratching going on...

Finally I decide to change the owner to 'sa', run the tests and they all work.  Then go and check the database in the 'domain2' domain and there it is the database owner is 'domain2\Administrator'.

So if anyone else runs into this issue, check your database owner first.

Don't ask about the domains, there are many (they are there to replicate our clients environment). And I did not have user access to domain2, but I did have access to the database server.

Wednesday, 5 August 2015

Anonymous types are internal

When testing against anonymous types you need to know that they are internal to the assembly they are declared in.

Add an InternalsVisibleTo assembly attribute to the declaring assembly to resolve this or you will get RuntimeBinderException exceptions like the following:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'object' does not contain a definition for 'Success'
For more detailed explanations and samples have a look at:

Tuesday, 4 August 2015

The referenced assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' could not be found

I got the following error on an old project in Visual Studio 2010 where I upgraded to AutoMapper 3.1.0:
The referenced assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' could not be found
The problem is the version of FxCop that comes with VS2010.  To resolve the problem I copied the FxCop folder for VS2012 (%ProgramFiles%\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\FxCop) over the FxCop folder for VS2010 (%ProgramFiles%\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop).

Monday, 3 August 2015

The source at nuget.org [https://www.nuget.org/api/v2/] is unreachable. Falling back to NuGet Local Cache

I started getting the following error while trying to use Install-Package:
The source at nuget.org [https://www.nuget.org/api/v2/] is unreachable. Falling back to NuGet Local Cache
It was driving me insane as it started out being intermittent and restarting Visual Studio would fix it for a while.  Finally did some googling and turns out you can specify a -Source parameter like so:
Install-Package AutoMapper -Source nuget.org
This worked for me.

Monday, 25 May 2015

Do not control the flow of your code using Exceptions

This is old news, but I constantly see code that does this.  You would think that the name Exception would make the intent of exceptions clear.  Don't throw an exception when a simple condition check would do.


Tuesday, 23 September 2014

Enable HTTP Compression in IIS Express

Open a Command Prompt as Administrator.  Go to the IIS Express installation folder

  • 32 bit : cd %programfiles%\iis express 
  • 64 bit: cd %programfiles(x86)%\iis express
Run the following command to enable dynamic compression:
appcmd set config -section:urlCompression /doDynamicCompression:true
You should see the following message:
 Applied configuration changes to section "system.webServer/urlCompression" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"
 Now add the mime-types to compress.  I'm using wildcard entries.  Static types first:
appcmd set config /section:httpCompression /staticTypes.[mimeType='*/*'].enabled:"true" /commit:apphost
You should see the following message:
Applied configuration changes to section "system.webServer/httpCompression" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"
Now for the dynamic types:
 appcmd set config /section:httpCompression /dynamicTypes.[mimeType='*/*'].enabled:"true" /commit:apphost
And the final message you should see:
 Applied configuration changes to section "system.webServer/httpCompression" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"

Reference: http://www.iis.net/configreference/system.webserver/httpcompression

Thursday, 18 September 2014

Less Compiler for Eclipse

I'm doing a project in Java and using Eclipse as my IDE.  This is a note to myself on what plug-ins I am installing.  Please note I am doing this all on Windows 7 and 8.1.

So first thing, install node (I use chocolatey for my Machine Package Manager).
C:\> choco install nodejs.install
I'm using the nodejs.install as it installs node and npm under "Program Files" and sets up the system PATH.  Close and re-open the command prompt before continuing.

Now we install less using npm (Node Package Modules).
npm install less -g
 We need to be able to edit LESS files in Eclipse and for that I'm using Eclipse plugin for LESS
LESS is a language which extends CSS with dynamic behavior such as variables, mixins, operations and functions. This plugin extends the Eclipse IDE by providing handy features to edit and compile LESS stylesheets.
You can drag the install button below onto Eclipse and it will install the plug-in.


To automatically build the LESS files as they are changed I used Maven and included the lesscss-maven-plugin.

Tuesday, 16 September 2014

Need to create a VM from a windows image?

This is just what I needed.  I had the ISO for Windows 7  and I needed to create a new Hyper-V VM for some testing I needed to do.  Enter Convert-WindowsImage.ps1.  I simply ran the ".\Convert-WindowsImage.ps1 -ShowUI" command in PowerShell, pointed it to the .ISO and created the VM.  Quick and painless.