NuGet logo

Nuget Package restore issues

After upgrading Nuget on VS2013, we’ve started hitting an issue where Nuget won’t restore packages. We get error messages similar to this:

Error 21 Could not find a part of the path 'C:\Dev\YourProject\ \packages\Microsoft.AspNet.WebApi.Core.5.2.3'.

I’ve found out that there is a change to the way Nuget picks up files. To get it to work you need to edit the file NuGet.targets changing the line:

<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>


<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(SolutionDir)\</RestoreCommand>

This sorts the issue.


Creating a multi project solution in VS2013

Ok, so this is probably a bit out of date as VS2019 is due out soon, but one of my clients is still using VS2013 as their main IDE, as they can’t update one of their projects for various reasons.

The project I’m working on them with is an AngularJS front-end to a micro-services architecture with around 20 micro-services. Creating a new service can be a bit of a pain, especially keeping them in line with internal standards, therefore I created a multi-project template to create a new service, and it does it in around 5 minutes from scratch to a working WebApi service.

I followed the guide here:, but there are a couple of gotchas.

    1. Take a working solution and copy it into a new folder, remember to remove source control bindings.
      folder structure
    2. Strip the solution to a bare bones solution that provides a working example of what you want do do. For this project, I have one data model, one DTO, one repository & interface, one service and interface and one WebAPI controller with one endpoint.solution Explorer
    3. Check that it still runs.
    4. Clean the solution, delete contents of bin and obj directories  in each project.
    5. In the File menu choose Export Template, and export each project. These will be exported to a folder like C:\Users\XXX\Documents\Visual Studio 2013\My Exported Templates
      Export Template Menu Item
      Export Template Page 1

      Export Template Page 2
    6. Copy each of them into the respective project folders and rename them to match the project name.
      Project contents
    7. Create a root.vsTemplate file – Refer to the guide for more info on this.
    8. Select the project folder and the root.vsTemplate (exclude the solution file, packages folder and .nuget folder) and right click –> Send to –>Compressed (zip) file.
    9. Rename the zip file and copy it to C:\Users\XXX\Documents\Visual Studio 2013\Templates\ProjectTemplates.
    10. Open a new copy of Visual Studio and select File\Create a new project, search for your template and create a new project.
    11. You should have a fully working WebApi.
    12. You can now add the package to a VSIX project and make that available for everyone to use.