Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the EnsureNuGetPackageBuildImports target?

In some of my csproj files I have this but some dont:

  <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>

What exactly is this and why do I need it? My other projects are restoring their packages just fine without it.

I am using VS2013 and NuGet 2.8.

like image 789
Dave New Avatar asked Feb 28 '14 08:02

Dave New


1 Answers

It ensures that the imported .props and .targets files are indeed imported. NuGet has supported NuGet MSBuild support since 2.5. EnsureNuGetPackageBuildImports code was added in September, but I think it is a 2.8 change. Unfortunately, it looks like a non-backward compatible change. We have some developers on 2.7 who will now need to upgrade to 2.8. I found EnsureNuGetPackageBuildImports in Common/MsBuildProjectUtility.cs on line 11.

like image 134
Cameron Taggart Avatar answered Nov 01 '22 09:11

Cameron Taggart