Thursday, October 29, 2015

Quick PowerShell Script for getting JSON.NET working with SQL 2012 Data tools on Windows 2012

Quick Description:  SQL Server Data Tools for SQL 2012 on Windows 2012 has JSON.NET installed, but can't find it at runtime.

NewtonSoft's super-awesome, saved my life JSON.NET Framework for .NET is so solid, but the SQL 2012 script component on 2012 is temperamental about remembering it's installed (when installed with NuGet.  On older versions of windows, the solution is to run a command-line GAC, but this proves difficult on Windows 2012.

What Worked for Me:
Script shamelessly (and gratefully) cribbed from this excellent TechNet article on using PowerShell to generally GAC a .dll on Windows 2012.

Download the package to the machine
Expand the package and drop the files to their final location

In PowerShell 2.0, for a script component referencing .Net 4.0 (the default for SQL 2012 Data Tools), this would be the script example.

[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")          
$publish = New-Object System.EnterpriseServices.Internal.Publish          

No comments:

Post a Comment