Grial nuget package breaks build on mobile.azure.com - azure

I recently added grial nuget packages to a xamarin solution.
It works fine locally but the build fails on mobile.azure.com.
I have used the nuget command line to add the new package source, including the credentials as a username / encrypted password.
It still breaks the build though, but this time with the error
"Data unprotection failed."
Has anyone come across this before, and do you have any possible solution?
thanks

You need to consider adding a nuget.config file. Below is an example that we used to include our Proget Feed.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="true" />
<add key="automatic" value="true" />
</packageRestore>
<packageSources>
<add key="NRTH Proget" value="http://proget.nrth.com/nuget/nuget" />
</packageSources>
</configuration>
Just drop this file in the same folder as your solution (.sln) file.

Related

azure devops artifacts save Nugets to feed as backup incase nuget.org will be down

we want to keep the Nugets we use in our feed in case nuget.org will be down.
Under NuGet.Config we did:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="Nugets" value="https://pkgs.dev.azure.com/<ourOrganization>/<ourProject>/_packaging/Nugets/nuget/v3/index.json" />
</packageSources>
<packageRestore>
<!-- The 'enabled' key is True when the "Allow NuGet to download missing packages" checkbox is set.
Clearing the box sets this to False, disabling command-line, automatic, and MSBuild-integrated restore. -->
<add key="enabled" value="True" />
</packageRestore>
</configuration>
Now if I go to the artifacts -> Nugets I can see some of the package, appear as NugetGallery, but not all of them.
For example Newtonsoft.Json is missing.
Also when I look at the source - why are all of them under Nugetgalley, and not 'this feed'?
Thank you for your help.

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.

Where is my Azure ADO token stored locally?

Looking in my machine nuget config I can see my ADO feed is registered, but there's no ADO token in it:
(C:\Users\user\AppData\Roaming\NuGet\NuGet.config)
<?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="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
<add key="dev.myfeed.com" value="https://pkgs.dev.azure.com/myfeed/_packaging/myfeed/nuget/v3/index.json" />
</packageSources>
<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>
</configuration>
Running a dotnet restore on my project successfully downloads a package which only exists in this feed, and I can't understand how it succeeds? The feed requires a token to authenticate against, and there's no token in my machine NuGet.config file. Has it retrieved the token from somewhere else?
Has it retrieved the token from somewhere else?
The credentials are stored in Azure Artifacts Credential Provider. The Azure Artifacts Credential Provider automates the acquisition of credentials needed to restore NuGet packages as part of your .NET development workflow. We need to install the latest .NET Core SDK and credential provider first when we use dotnet with Azure Artifacts feeds.
Here is my sample when I run dotnet restore and verify with credential provider. I need to open a browser and sign in my account:

Proxy interfering with Azure Server/ NuGet Push Error404

I tried to Push a nupkg to Artifacts in Azure DevOps Server, but it fails with the following error:
---> (Inner Exception #0) NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source http://<DomainName>/nuget/v3/index.json ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).
I suspect that the problem might be the corporate's proxy that interferes with Azure DevOps Server.
Proxy's configuration looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<config>
<add key="http_proxy" value="http://ep.threatpulse.net:80" />
</config>
</configuration>
Also, I tried to configure the proxy settings and it still didn't work.
Does anybody have any idea about what could be wrong or how can I fix this?
Version Dev17.M153.5
Proxy interfering with Azure Server/ NuGet Push Error404
Yes, that error is indeed caused by proxy and what you did is also correct.
Just make sure you have add proxy settings into Nuget.Config file, which located in following path:
%appdata%\NuGet\NuGet.config
NuGet.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="http_proxy" value="http://ep.threatpulse.net:80" />
<add key="https_proxy" value="http://ep.threatpulse.net:80" />
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
You could check this thread for some more details.
If it still not work for you, I suggest you contact your office IT to confirm proxy setting.
Hope this helps.

It is possible to change packages installation directory for Package Manager Console?

I'm using nuget integration with msbuild (visual studio 2012) to automatically restore broken packages. Below you can see my .nuget/nuget.config file for solution:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<add key="enabled" value="True" />
</packageRestore>
<disabledPackageSources />
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<config>
<add key="repositoryPath" value="..\..\Lib\NuGet\Packages" />
</config>
</configuration>
My packages directory moved outside from solution. This works fine during build, but Package Manager Console still using $(SolutionDir)\packages to install (and restore) packages.
It is possible to change packages directory for "Package Manager Console"?
nuget.config
You got the first part:
<config>
<add key="repositoryPath" value="..\MySuperCoolPackages" />
</config>
But you have to tell the command line about the nuget.config file explicitly.
C:\SomeFolder\NuGet.exe install "C:\MySolution\.nuget\packages.config" -ConfigFile "C:\MySolution\.nuget\nuget.config"
When you create nuget.config with repositoryPath you need to restart VS for it to be reread and console to be aware of it.
Edit: #DmitryBykadorov weird, may be your nuget is out of date? There was an early problem where due to config being in .nuget subfolder and not in .csproj's current>parent>parent>etc path it wouldn't see it and required one nuget.config with restore info and one (typically next to .sln or .csproj itself) with repositoryPath, but my VS2012 with whatever latest nuget it comes with works fine with config below. May be your global nuget config somehow affects it, or your solution needs hard clean/rebuild?
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<config>
<add key="repositoryPath" value="..\..\lib" />
</config>
</configuration>

Resources