Skip to content

Instantly share code, notes, and snippets.

@mseankelly
Created July 8, 2012 00:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mseankelly/3068663 to your computer and use it in GitHub Desktop.
Save mseankelly/3068663 to your computer and use it in GitHub Desktop.
Subvert NuGet 2.0's insistence that the developer explicitly enable package restore.
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<!--Update the NuGet.target file that is generated when you enable NuGet package restore with the following tweak.-->
<!--This will make it so that everyone pulling the project from source control will automatically pull the requisite NuGet packages the first time they build.-->
<!--While I understand why MS put this in place, it really doesn't make sense in the context of my current team (or any other team I've ever worked on).-->
<SetEnvironmentVariable EnvKey="EnableNuGetPackageRestore" EnvValue="true" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>
@ferventcoder
Copy link

Nice! I did something VERY similar except made it a nuget package for all http://nuget.org/packages/NuGetEnablePackageRestore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment