0

I have a project under source control (TFS) and it physical location is:

C:\repositry\devRep\application\DevEnv\Test\Project1

I have moved solution file (.sln) and its project to one level up using TFS (Source Control Explorer Move option)

C:\repositry\devRep\application\DevEnv\Project1

However, I did not move .nuget folder one level up and it is still at original location

C:\repositry\devRep\application\DevEnv\Test\Project1

Problem:

If i build i get the following error

This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.

Also, If i try to open package.config under .NuGet folder of my solution, i get this error

Downloading package 'NuGet.Build' failed.

I am sure it is becuase i did not move it up along with solution and projects BUT i am not sure how do i move it up?

? Same approach as i did for projects ? just delete this folder and VS will auto create it?

Any suggestion?

simbada
  • 940
  • 4
  • 24
  • 43

2 Answers2

0

One way is that:

  1. Open solution in VS 2013
  2. Right click the solution=>select Enable Nuget package restore, then it will add .nuget folder with necessary files.

Another way is that you could copy .nuget folder to destination solution folder directly.

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
0

It seems you are still using MSBuild-Integrated package restore. Solutions currently using MSBuild-Integrated package restore can be migrated to Automatic Package Restore.

Please try the steps below:

  1. Close down Visual Studio
  2. Remove the NuGet.exe and NuGet.targets files from the solution's .nuget folder. Make sure the files themselves are also removed from the solution workspace.
  3. Retain the NuGet.Config file to continue to bypass adding packages to source control.
  4. Edit each project file (e.g., .csproj, .vbproj) in the solution and remove any references to the NuGet.targets file. Open the project file(s) in the editor of your choice and remove the following settings:

 <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><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>
  1. Testing the migration

a. Save the solution and close Visual Studio.

b. Remove the packages folder located under the solution root.

c. Reopen the solution in Visual Studio.

d. Rebuild the solution. Automatic Package Restore should:

  • Download and unzip each package

  • Ignore adding the packages to source control

More information, see: https://docs.nuget.org/consume/package-restore/migrating-to-automatic-package-restore

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39