Disabling NuGet Package Restore

You’ve enabled NuGet Package Restore and want to reverse that decision? Follow the steps below for every csproj in your solution:

  • Close down the solution
  • Delete the .nuget folder on the solution level
  • Open up each csproj in a text editor
  • Find the following XML tags and delete them:
<RestorePackages>true</RestorePackages>  
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />  
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">  
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>

AngularJS 1.4 – Declaring a Controller

I’ve been following a few tutorials that describe declaring a MainController. However the tutorials a pre AngularJS 1.3x and are no longer valid. Previous AngularJS allowed you to define a controller globally . As of 1.3x this is no longer the case and you must declare your Controllers inside angular modules. Here’s an example:


var githubViewerApp = angular.module('githubViewer', []);

Declare a new module and give it a unique name. Then assign module to a variable.


var MainController = function MainController($scope, $http) { }

Create your MainController. This is where all your functions and service calls will sit.


githubViewerApp.controller("MainController", ['$scope', '$http', MainController]);

Now bind the MainController variable to the module variable. The variables with $ signs are included in the function parameters to help support minification. Without this minifiers would rename the variable and angular would be unable to bind the parameters to the view.

HTML with in-line Razor

This little gotcha keeps biting me in the ass every time I move away from Razor for a while. So I’ve decided to blog so this time I’ll remember.

When you want to insert some razor syntax in-line within a HTML tag. Make sure you include the @ delimiter on any further statement.


Following example attempts to add a class based on a bool value in the model.

The class show does not render:

<div class="@if(Model.Show) { Html.Raw("show") }"> 

The Html.Raw helper method is returning a MvcHtmlString however it will not output the value unless you tell it to by prefixing the statement with @. Now it renders !

<div class="@if(Model.Show) { @Html.Raw("shoe"); } }">