NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 249 forks source link

With http sources, when the protocol version is not specified, NuGet should detect the version by contacting the source instead of assuming v2 #10493

Open jongio opened 3 years ago

jongio commented 3 years ago

I want to be able to create short links for my package feed URLs i.e.

https://aka.ms/azsdk/net/feed -> https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json

If I do this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
<ItemGroup>
    <PackageReference Include="Azure.Data.Tables" Version="3.0.0-dev.*" />
  </ItemGroup>
     <PropertyGroup>
    <RestoreSources>https://aka.ms/azsdk/net/feed;https://api.nuget.org/v3/index.json</RestoreSources>
  </PropertyGroup> 
</Project>

I get this:

Determining projects to restore...
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://aka.ms/azsdk/net/feed/FindPackagesById()?id='Azure.Data.Tables'&semVerLevel=2.0.0'.
  The content at 'https://aka.ms/azsdk/net/feed/FindPackagesById()?id='Azure.Data.Tables'&semVerLevel=2.0.0' is not valid XML.
    For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
  Retrying 'FindPackagesByIdAsyncCore' for source 'https://aka.ms/azsdk/net/feed/FindPackagesById()?id='Azure.Data.Tables'&semVerLevel=2.0.0'.
  The content at 'https://aka.ms/azsdk/net/feed/FindPackagesById()?id='Azure.Data.Tables'&semVerLevel=2.0.0' is not valid XML.
    For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method.
/usr/share/dotnet/sdk/5.0.100/NuGet.targets(131,5): error : Failed to retrieve information about 'Azure.Data.Tables' from remote source 'https://aka.ms/azsdk/net/feed/FindPackagesById()?id='Azure.Data.Tables'&semVerLevel=2.0.0'. [/mnt/c/code/devfeed/devfeed.csproj]
/usr/share/dotnet/sdk/5.0.100/NuGet.targets(131,5): error :   The content at 'https://aka.ms/azsdk/net/feed/FindPackagesById()?id='Azure.Data.Tables'&semVerLevel=2.0.0' is not valid XML. [/mnt/c/code/devfeed/devfeed.csproj]
/usr/share/dotnet/sdk/5.0.100/NuGet.targets(131,5): error :   For security reasons DTD is prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method. [/mnt/c/code/devfeed/devfeed.csproj]

It would be great if I could specify a short link in csproj file and nuget follows the redirect.

azsdke2e azsdke2e2

nkolev92 commented 3 years ago

The root cause here is that NuGet does feed type detection before contacting the sources.

The improvement would be for NuGet to detect the correct feed type automatically.

Note that this would work if the link had index.json in the name, which is how the type of source is detected. Retitling as such.

jongio commented 3 years ago

I tried this:

Created aka https://aka.ms/azsdk/net/feed/index.json

which points to https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json

and it works.