Reputation: 93
I have created ASP.net Core project using Visual studio 2017. I need to compile/debug this project on Build machine using Visual studio 2017. But I don't have internet on build machine.
I have exact same project on my dev machine that I can build with full internet access. I have full internet access on dev machine.
How do I copy all reference Nuget packages to Build machine so that I can compile/debug application on Build machine?
In .net framework project, I could copy entire 'packages' folder and it would work. While in .NET core there is no packages folder.
I tried copying packages from my dev machine's C:\Users<user>.nuget to C:\Users<user>.nuget of build machine (which doesn't have internet) which didn't work.
thanks, atul
Upvotes: 1
Views: 2204
Reputation: 93
Thanks everyone spending time answering. that gave me many hints to look at. Following settings in C:\Users\myusername\AppData\Roaming\NuGet\NuGet.Config solved my problem.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
<disabledPackageSources>
<add key="Microsoft Visual Studio Offline Packages" value="true" />
<add key="custom" value="true" />
</disabledPackageSources>
<packageSources>
<add key="Package source" value="C:\Users\myusername\.nuget\packages" />
</packageSources>
</configuration>
Originally, it had following entries which was causing problem as machine didn't have internet access.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="artifactory" value="https://<artifactory URL>/artifactory/api/nuget/v3/nuget-remote" />
</packageSources>
</configuration>
All the packages are manually copied to build machine into C:\Users\myusername\.nuget\packages folder.
Upvotes: 1
Reputation: 107
Add Nuget.config file in your root directory where the solution situated.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="PackageSource" value="c:\packages" />
</packageSources>
</configuration>
And you can use this command to build your project
dotnet restore $PROJECT_NAME --configfile ./NuGet.config
dotnet build $PROJECT_NAME --no-restore
Upvotes: 1