Windows Azure Cache installation from Nuget gets rolled back

Recently I came across this strange issue while trying to upgrade the Windows Azure Cache version using NuGet. In NuGet only the latest version is visible by browsing and for any of the previous versions the power shell integrated with Visual Studio needs to be used.

So we used the following

Visual Studio > Tool > Package Manger console 

PM> Install-Package Microsoft.WindowsAzure.Caching -Version 1.8.1.0

Installing 'Microsoft.WindowsAzure.Caching 1.8.1.0'.

You are downloading Microsoft.WindowsAzure.Caching from Microsoft, the license agreement to which is available at https://go.microsoft.com/fwlink/?LinkID=235167.

Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.

Successfully installed 'Microsoft.WindowsAzure.Caching 1.8.1.0'.

Adding 'Microsoft.WindowsAzure.Caching 1.8.1.0' to CloudWorkerRole.

'Microsoft.WindowsAzure.Caching\PerformenceCounters.xml' already exists.   

Skipping...

'Microsoft.WindowsAzure.Caching\ClientPerfCounterslnstaller.exe.config' already exists, skipping...

'Microsoft.WindowsAzure.CachingClientPerfCountersInstaller.exe' already exists. 

Skipping...

Uninstalling 'Microsoft.WindowsAzure.Caching 1.8.1.0'.

Successfully uninstalled 'Microsoft.WindowsAzure.Caching 1.8.1.0'.

Install failed. Rolling back…

Install-Package : The method or operation is not implemented

At line:1 char: 1

+ Install-Package Microsoft.WindowsAzure.Caching -Version 1.8.1.0

+ CategoryInfo : NotSpecified: (:) [Install-Package],  

NotImplementedException

+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,

 NuGet.PowerSheII.Commands.InstallPackageCommand

It starts installing and halfway starts rolling back. With Time Travel Tracing (also known as iDNA tracing) we found the following. iDNA by itself is a vast topic and I will not cover it here but you can search for lot of material available in the internet. The part below is esoteric and I took the help of my senior Mike Wong (Senior EE) to unravel the mystery.

NuGet is calling

 Serena_VsCMPkg!Serena.CM.VisualStudio.Package.SerenaVsCMPkg.IsItemUnderSCC(System.String)+0x1d

 …

NuGet_VisualStudio!EnvDTE.SourceControl.IsItemUnderSCC(System.String)+0x2

NuGet_VisualStudio!NuGet.VisualStudio.ProjectExtensions.EnsureCheckedOutIfExists

NuGet_VisualStudio!NuGet.VisualStudio.VsProjectSystem.AddFile

 

If we look at the implementation of IsItemUnderScc in the Serena.VsCMPkg.dll we see the following

 .method public hidebysig newslot virtual final

 instance bool IsItemUnderSCC([in] string ItemName) cil managed

 {

  // Code size 6 (0x6)

  .maxstack 8

   IL_0000: newobj instance void [mscorlib]System.NotImplementedException::.ctor()

   IL_0005: throw

  } // end of method SerenaVsCMPkg::IsItemUnderSCC

So this is causing the issue of the Nuget package installation to rollback. The original message in package manager is

 Install-Package : The method or operation is not implemented.

 We unbounded Visual Studio from Source Control.

 Visual Studio > Tools > Options > Source Control > Plug-in Selection, change Current source control plug-in to “None”.

 We are preventing NuGet from calling into the source control. Once we have disconnected the source control the NuGet and ran the installation command from the Visual Studio Package Manager it installed fine. So the crux of it is if you are in a situation where the Windows Azure Cache NuGet package is rolling back check if it is under source control. Detach from source control and try to install the package again.