Visual Studio 2017 – Add, Remove or Update DotNetCLITools references – 7th March 2017

Visual Studio release notes as of 7th March release notes state that the DotNetCLITools packages cannot currently be managed by the Nuget Package Manager and must be edited manually in the csproj.

After migrating my current projects, I finally figured out that it wasn’t just me that was struggling to find the place to manage these packages. There’s no intellisense in this area either. Eventually I replaced my pre-release references with the following:

In your csproj file: 

<ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />
 </ItemGroup>

This allows visual studio to run the dotnet commands for building, database, bundling and publishing!

Sources: https://www.visualstudio.com/en-us/news/releasenotes/vs2017-preview-relnotes

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>