Procedure to enable automatic nuget restore in VS 2015/2017
> Create a folder with name ".nuget" in the solution root
> Add these 3 files in to ".nuget folder"
1. "nuget.config"
2. "NuGet.exe"
3. "NuGet.targets"
> Add these tag in you all project file by using node pad or by VS(unload project to edit)
1. <NuGetPackageImportStamp></NuGetPackageImportStamp>
<RestorePackages>true</RestorePackages>
Add this entry inside "<PropertyGroup>" tag.
2. <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>
Add this in "<project>" tag & would be good if these all enties added in ending of tag.
> This step is addtional but recomemded sometimes.
Add a file with named "repositories.config" inside packages folder & refer all libraries "packages.config". if libraries dont have "packages.config", then no need to refer those.
eg:- <?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\Myportal\packages.config" />
<repository path="..\Myportal.UnitTests\packages.config" />
<repository path="..\\Myportal.Core\packages.config" />
</repositories>
Here "Myportal" is example taken to represnt library.
> Create a folder with name ".nuget" in the solution root
> Add these 3 files in to ".nuget folder"
1. "nuget.config"
2. "NuGet.exe"
3. "NuGet.targets"
> Add these tag in you all project file by using node pad or by VS(unload project to edit)
1. <NuGetPackageImportStamp></NuGetPackageImportStamp>
<RestorePackages>true</RestorePackages>
Add this entry inside "<PropertyGroup>" tag.
2. <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>
Add this in "<project>" tag & would be good if these all enties added in ending of tag.
> This step is addtional but recomemded sometimes.
Add a file with named "repositories.config" inside packages folder & refer all libraries "packages.config". if libraries dont have "packages.config", then no need to refer those.
eg:- <?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\Myportal\packages.config" />
<repository path="..\Myportal.UnitTests\packages.config" />
<repository path="..\\Myportal.Core\packages.config" />
</repositories>
Here "Myportal" is example taken to represnt library.
No comments:
Post a Comment