1

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

2
  • When you say "it didn't work", what was the error? Commented Nov 12, 2020 at 16:08
  • Nuget packages are stored in C:\Users\<user>\.nuget\packages. You will have to copy them to a directory on your build machine, then set it as a local package source in Visual Studio Commented Nov 12, 2020 at 16:08

2 Answers 2

1

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 
Sign up to request clarification or add additional context in comments.

1 Comment

I tried that. but didn't work. it was always throwing error -error NU1101: Unable to find package NuGet.Frameworks. No packages exist with this id in source(s): PackageSource
1

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.

1 Comment

After above changes, i could see obj\project.assets.json with following reference "packageFolders": { "C:\\Users\\myusername\\.nuget\\packages\\": {}, "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {} }

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.