I am trying to configure multiple Nuget source in nuget.config. Nuget.config is added to the root of the project. With same config I can successfully dotnet build my app on my macbook but when I run the same config in linux I get the following error.
/opt/rh/rh-dotnet31/root/usr/lib64/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Unable to load the service index for source https://gitlab.xxxyy.gov/api/v4/projects/id/packages/nuget/index.json [/var/www/folder/member/Member.sln]
/opt/rh/rh-dotnet31/root/usr/lib64/dotnet/sdk/3.1.100/NuGet.targets(123,5): error : Response status code does not indicate success: 401 (Unauthorized). [/var/www/netcoreapp3.1/member/Member.sln]
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="gitlab" value="https://gitlab.senate.gov/api/v4/projects/449/packages/nuget/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageSourceCredentials>
<gitlab>
<add key="Username" value="xyz" />
<add key="ClearTextPassword" value="dhdhdhdh" />
</gitlab>
</packageSourceCredentials>
</configuration>
I figured it out. I had to manually add source nuget source Add -Name "gitlab" -Source "https://gitlandomain/api/v4/projects/id/packages/nuget/index.json" -UserName xyz#domain.com -Password ddhdhdgdgsgv
After this dotnet nuget restore/build works like charm.
Related
I have private nuget repo packages in my solution and when I restore them to build my app in Visual Studio, I get the following error
Severity Code Description Project File Line Suppression State
Error NU1301 Unable to load the service index for source https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json. MyPrivate.Project.Repository C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj 1
With the popular resolution
Nuget connection attempt failed "Unable to load the service index for source"
I tried deleting %AppData%\Roaming\NuGet\NuGet.Config and restarting VS which is not working for me.
My Nuget.Config looks like this.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyGet.orgV3" value="https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
Even tried dotnet restore --interactive
But in futile
dotnet restore --interactive
Determining projects to restore...
C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj : error NU1301: Unable to load the service index for source https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json. [C:\Pth\To\source\repos\Project\src\Project.name\Project.csproj]
The repo needs either a password/AzureAAD identity for access and I have logged into the visual studio/terminal with the account I have access to the private repo. I think this is somehow stopping the service index to load, but I have a roadblock to achieving it.
The access to the private package repo:
My Package sources looks like this:
I got a dirty solution.
I decided to use private nuget repo username and password in the Nuget.Config ( at least locally ).
I changed the Nuget.Config to:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="MyGet" value="https://myprivate.privatenuget.org/F/privatepackages/api/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<MyGet>
<add key="Username" value="myusername" />
<add key="ClearTextPassword" value="mysecretpassword" />
</MyGet>
</packageSourceCredentials>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
I deleted the NuGet.Config from NuGet folder by running
Then, from VS Developer PowerShell Terminal ( because it is not working with the UI build tab ) I ran dotnet restore and the packages got restored.
I'm looking for better answers to avoid passwords in clear text.
The issue was that I messed with the private package repository password that would be prompted when the VS loads the project. If you entered it wrong once, you would never get the package restored.(which is pathetic....as the reason for the restoration failure is not explicit.)
But we can easily solve this by the following steps:
If Visual Studio does not prompt for credentials but the logging Output shows that you did not authenticate correctly, then go to
Control Panel\User Accounts\Credential Manager
and click "Windows Credentials". You can remove stored credentials for nuget/github there. If they become invalid - for example because you regenerated a token - Visual Studio does not prompt to overwrite the invalid credentials, but after removing the credentials and restarting Visual Studio you do get the prompt.
I found it from the stackoverflow answer here: Nuget Package Source is not prompting for credentials
Using Net 6 I have the project structure:
nuget.config
project.code-workspace
- Core
Core.csproj
- Api
Api.csproj
- Sim
notebook.ipynb
My Nuget.config is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="mysrc" value="https://pkgs.dev.azure.com/me/_packaging/mysrc/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<moget>
<add key="Username" value="mysrc" />
<add key="ClearTextPassword" value="password" />
</moget>
</packageSourceCredentials>
</configuration>
The package mysrc is working fine with my Core and Api project.
But when I run the Net Interactive Notebook I get the error:
Error: /usr/local/share/dotnet/sdk/6.0.101/NuGet.targets(130,5): error : Unable to load the service index for source ... : error :
Response status code does not indicate success: 401 (Unauthorized).
How to solve this?
UPDATE: I fixed this by changing to AspNetCoreModule and used out of process.
This mvc site has been running for a while but after the last deploy, it will no longer run. The event log shows this error:
Application <path to app> failed to start. Exception message:
Application DLL was not found at <path to app>\.\Proxy.dll. Confirm the application dll is present. Single-file deployments are not supported in IIS.
In the csproj file, I have this:
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
And, I publish to a local folder like so:
dotnet publish <path to source>/Proxy.csproj -c Release -o ./build -r win10-x64 --self-contained true
Finally, the web config is this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Proxy.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</configuration>
And, since this ran up until last update, I believe IIS (version 8.5- Win Server 2012 R2) is setup correctly. Under modules, I see AspNetCoreModuleV2. The Apppool is setup with Integrated pipeline and no managed code.
Can somebody help me with this? Thanks. Eric
How I do add packages sources in my project?
In my Visual Studio, i go to tools -> options -> Nuget Package Manager -> Package Sources.
And add the package information that in this case is not in Nuget. Now in the App Center I did not find this information and with this my project does not compile
You can create a NuGet.config file as described in the docs.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget" value="https://api.nuget.org/v2/index.json" />
<add key="MyGet" value="https://www.myget.org/F/MyUsername/api/v2/index.json" />
<add key="MyAuthNuget" value="https://nuget.example.com/v2/index.json" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<packageSourceCredentials>
<MyAuthNuget>
<add key="Username" value="$USER_VARIABLE" />
<add key="ClearTextPassword" value="$PASSWORD_VARIABLE" />
</MyAuthNuget>
</packageSourceCredentials>
</configuration>
Maybe this will also help somebody. For me the above solution haven't worked. So what I've discovered - always check if official source of packages is same as in your config. For now nuget source have changed to version 3:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<activePackageSource>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
</configuration>
Has anyone had success building an ASPNET5 application in VSTS with a local (not public facing) Nuget server as a feed? Following these steps: https://msdn.microsoft.com/Library/vs/alm/Build/azure/deploy-aspnet5 I can see the script restoring but it always errors out on my local package. I am sure I am configuring something wrong. This is what I have tried:
Add a Nuget Installer task with a arg to my solution and NuGet arguments nugete.exe -source "https://www.nuget.org/api/v2/;http://mynugetserver" (and I tried including no Nuget arguments and including a Nuget.config in the root of my solution). However, the build runs into a an exception saying it cant find the local url: System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The remote name could not be resolved: 'mydomain'. Okay I understand that, but I do I get it to recognize a local URL?
After researching I thought I would have to use the Package Manager Extension for VSTS. So I loaded my packaged on there successfully, but when I included that package URL in my Nuget.config I get a bunch of unauthorized responses from the PreBuild.ps1 because it is trying to look at the VSTS package URL too. And that is where I am now.
Current Nuget.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<config>
<!--DO I NEED TO INCLUDE MY PROXY INFOR HERE I AM BEHIND ONE AT WORK-->
</config>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<activePackageSource>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</activePackageSource>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
<add key="Local" value="https://vstsurl/DefaultCollection/_packaging/Local/nuget/v3/index.json" />
<add key="Company Nuget Gallery v2" value="http://mydomain/nuget/api/v2" />
</packageSources>
</configuration>
UPDATE
if I use the Package Manager on VSTS these are the warnings / exceptions all which seem to come from the local feed. not sure why it is using the local feed for all the external packages
System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
... other exceptions here
----------
Restore failed
If you are using the build agent hosted by VSTS and your nuget server is in local (Cannot access from internet), the package restore will fail since the build agent cannot find your nuget server. You'd either configure your nuget server so that it can be accessed from internet or deploy your own build agent in the same intranet with your nuget server.