I've been using this SO answer and this Powershell script to transform .NET config files.
The gist of the script is that it downloads a local version of nuget.exe, then uses this to download NuGet packages which will be used for the XDT transformations.
My problem is that when it invokes a line to download a NuGet package I'm told that the package cannot be found. For example...
Unable to find version '3.1.0' of package 'Microsoft.Web.Xdt'.
...even though nuget.org clearly states that this is valid - link. I've tried it with other packages and their publicly-stated versions, and receive the same message.
Another point to be aware of is that we have our own private NuGet feed. When I run the Powershell script it will also attempt to search that feed, which I don't want it to do, so I have added a nuget.config
file in the same directory as the Powershell script (I've also tried it in the same directory as the local nuget.exe) in which I have disabled our custom NuGet source...
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources>
<add key="DevOps" value="true" />
</disabledPackageSources>
<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>
Other than that <disabledPackageSources />
section the rest of this nuget.config was copied from my machine-level nuget.config.
Can anyone explain why this local instance of nuget.exe is unable to find any packages from nuget.org?