简体   繁体   中英

Azure Devops Pipeline build on OFFLINE server - NuGet packages?

My solution builds perfectly on my local machine and it uses Microsoft.Data.Sqlclient and Azure.Core nuget packages, but the solution does NOT build on our Azure Devops server because there is no internet access there. The error is "Error NETSDK1064: Package Azure.Core, version 1.20.0 was not found."

I put these packages in a .packages subfolder and created a Nuget.config file that I believe references this sub-folder, but no luck.

How can I tell our DevOps server to use find the Nuget packages in the .packages subfolder?

I finally got this to work through the NuGet Restore task placed before the build. I chose "custom" as the NuGet Restore command type, and the actual command was:

restore  CoreBZ2.sln -PackagesDirectory ..\packages

with ALL of the needed packages (all .nupkg files) in the "packages" subfolder of my solution. (CoreBZ2.sln is the name of my project/solution.)

I also had a NuGet.config file placed in the same folder as the solution and it looked like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageSources>
        <add key="nuget.org" value=".\packages" />
        <add key="Azure.Core" value=".\packages" />
    </packageSources>

    <config>  
        <add key="globalPackagesFolder" value=".\packages" />
        <add key="defaultPushSource" value=".\packages" />
    </config>
    <activePackageSource>
        <add key="All" value=".\packages" />
    </activePackageSource>
    <config>
        <add key="repositoryPath" value="$\..\packages" />
    </config>

</configuration>

There is probably a better way to do this, but this did finally result in a successful build on the offline DevOps server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM