I’ve a strange problem..I’m trying to build a pipeline in Azure DevOps for a .net project and trying the below options which are not fruitful, Need your thoughts on this.
I’m trying to build a solution file (.sln) for a .net project in Azure DevOps. The source control used is TFVC, we have a build server, azure DevOps agent installed on it and it’s running with Network service account.
Option 1
Running the task locally to get the packages mentioned in packages folder in nuget.config
Output – It’s not picking my mentioned packages path in nuget.config file instead it is picking C:Program Filesdotnetlibrary-packs
option 2
Our build server doesn’t access the Internet, So I’m trying to enable the proxy setting for IE using below script in azure DevOps pipeline using powershell task – Passing proxy server and by passlist in arguments list
Still this option also doesn’t work and its stats below **Erroras running the ‘restore’ operation with an ‘HTTP’ source: we don’t have certificate and when tried to apply a wildcard cert, unable to update the bindings- for http port used is 8080 and for https- “443 is not working”.
Option 1 -Running the task locally to get the packages mentioned in packages folder in nuget.config
For it I’ve created a “dotnet restore” task having below details
Display name – Restore Command- restore Path to projects- **/*.sln Feeds and authentication – Feeds to use I selected – Feeds in my NuGet.config Mentioned my nuget.config path (placed config file in the build server path)
**Nuget.config **
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="False" />
<add key="automatic" value="False" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
<packageSources>
<add key="Microsoft Visual Studio Offline Packages" value="E:packages" />
</packageSources>
</configuration>
Packages folder has all the required packages in the path.
When I try to run the task, it is picking the path – It throws error stating as below
error NU1101: Unable to find package Microsoft.NETCore.App.Ref. No packages exist with this id in source(s): C:Program Filesdotnetlibrary-packs, Microsoft Visual Studio Offline Packages error NU1102: Unable to find package Microsoft.WindowsDesktop.App.Ref with version (= 6.0.30) error NU1102: – Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 6.0.31 ] error NU1102: – Found 0 version(s) in C:Program Filesdotnetlibrary-packs error NU1102: Unable to find package Microsoft.AspNetCore.App.Ref with version (= 6.0.30)
It’s not picking my mentioned packages path in nuget.config file instead it is picking C:Program Filesdotnetlibrary-packs
Note- The above-mentioned packages 6.0.30 and 6.0.31 are placed in the “E:packages”
option 2:
Our build server doesn’t access the Internet, So I’m trying to enable the proxy setting for IE using below script in azure DevOps pipeline using powershell task – Passing proxy server and by passlist in arguments list
First Task – Proxy enable script
param ( [string]$ProxyServer, [string]$BypassList )
Set the execution policy
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force
Function to run command as administrator
function Run-AsAdmin { param ( [string]$command )
$processInfo = New-Object System.Diagnostics.ProcessStartInfo
$processInfo.FileName = "powershell.exe"
$processInfo.Arguments = "-Command `"& { $command }`""
$processInfo.Verb = "runas"
$processInfo.WindowStyle = "Hidden"
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $processInfo
try {
$process.Start() | Out-Null
$process.WaitForExit()
} catch {
Write-Error "Failed to run as administrator: $_"
}
}
Set the proxy settings
$proxyCommand = "netsh winhttp set proxy $ProxyServer bypass-list=$BypassList" Run-AsAdmin -command $proxyCommand Write-Host "Proxy settings: HTTP_PROXY=$ProxyServer , bypass-list=$BypassList"
Verify the settings
Run-AsAdmin -command "netsh winhttp show proxy"
The Output shows the proxy server and Bypasslist details, not sure if the above is really enabling the proxy.
**Second Task – dotnet core**
Display name – Restore
Command- restore
Path to projects- **/*.sln
Feeds and authentication – Feeds to use I selected – Feed(s) I select here
Use packages from this Azure Artifacts feed- Created a feed in Azure Artifact – BuildPackages
checked -Use packages from NuGet.org
**Nuget.config**
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="False" />
<add key="automatic" value="False" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
<packageSources>
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
Still this option also doesn’t work and it stats below **Error:**
error NU1302: You are running the ‘restore’ operation with an ‘HTTP’ source: http://<tfsurl>_packaging/BuildPackages/nuget/v3/index.json. NuGet requires HTTPS sources. To use an HTTP source, you must explicitly set ‘allowInsecureConnections’ to true in your NuGet.Config file. Please refer to https://aka.ms/nuget-https-everywhere for more information.
Please let me know what changes needs to be done.
Appreciate your help!