简体   繁体   中英

NuGet on mono behind proxy not able to connect to the internet

I have a Linux machine behind a corporate proxy.

For the proxy I have setup CNTLM to handle the authentication for me, so my proxy is located at http://localhost:3128 . CNTLM connects to a corporate proxy that uses NTLMv2.

Now when I try to run Nuget on Mono with the following command:

mono .nuget/nuget.exe list -Verbosity detailed -ConfigFile .nuget/NuGet.Config

It gives me the following error:

System.TypeInitializationException: An exception was thrown by the type initializer for NuGet.ProxyCache ---> System.ArgumentException: parsing '*.intranet' - Quantifier {x,y} following nothing. at System.Text.RegularExpressions.RegexParser.ScanRegex () [0x00000] in <filename unknown>:0 at System.Text.RegularExpressions.RegexParser.Parse (System.String re, RegexOptions op) [0x00000] in <filename unknown>:0 at System.Text.RegularExpressions.Regex..ctor (System.String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache) [0x00000] in <filename unknown>:0 at System.Text.RegularExpressions.Regex..ctor (System.String pattern) [0x00000] in <filename unknown>:0 at System.Net.WebProxy.CheckBypassList () [0x00000] in <filename unknown>:0 at System.Net.WebProxy..ctor (System.Uri address, Boolean bypassOnLocal, System.String[] bypassList, ICredentials credentials) [0x00000] in <filename unknown>:0 at System.Net.WebProxy..ctor (System.Uri address, Boolean bypassOnLocal, System.String[] bypassList) [0x00000] in <filename unknown>:0 at System.Net.WebRequest.GetSystemWebProxy () [0x00000] in <filename unknown>:0 at NuGet.ProxyCache..cctor () [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at NuGet.HttpClient.GetResponse () [0x00000] in <filename unknown>:0 at NuGet.RedirectedHttpClient.GetResponseUri (NuGet.HttpClient client) [0x00000] in <filename unknown>:0 at NuGet.RedirectedHttpClient.EnsureClient () [0x00000] in <filename unknown>:0 at System.Lazy System.TypeInitializationException: An exception was thrown by the type initializer for NuGet.ProxyCache ---> System.ArgumentException: parsing '*.intranet' - Quantifier {x,y} following nothing. at System.Text.RegularExpressions.RegexParser.ScanRegex () [0x00000] in <filename unknown>:0 at System.Text.RegularExpressions.RegexParser.Parse (System.String re, RegexOptions op) [0x00000] in <filename unknown>:0 at System.Text.RegularExpressions.Regex..ctor (System.String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache) [0x00000] in <filename unknown>:0 at System.Text.RegularExpressions.Regex..ctor (System.String pattern) [0x00000] in <filename unknown>:0 at System.Net.WebProxy.CheckBypassList () [0x00000] in <filename unknown>:0 at System.Net.WebProxy..ctor (System.Uri address, Boolean bypassOnLocal, System.String[] bypassList, ICredentials credentials) [0x00000] in <filename unknown>:0 at System.Net.WebProxy..ctor (System.Uri address, Boolean bypassOnLocal, System.String[] bypassList) [0x00000] in <filename unknown>:0 at System.Net.WebRequest.GetSystemWebProxy () [0x00000] in <filename unknown>:0 at NuGet.ProxyCache..cctor () [0x00000] in <filename unknown>:0 --- End of inner exception stack trace --- at NuGet.HttpClient.GetResponse () [0x00000] in <filename unknown>:0 at NuGet.RedirectedHttpClient.GetResponseUri (NuGet.HttpClient client) [0x00000] in <filename unknown>:0 at NuGet.RedirectedHttpClient.EnsureClient () [0x00000] in <filename unknown>:0 at System.Lazy 1[System.Object].CreateValue () [0x00000] in :0 `

It seems to want to parse a '*.intranet' string, although I'm not sure where it's getting that from. My Nuget.Config file looks like this:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <solution>
      <add key="disableSourceControlIntegration" value="true" />
    </solution>
    <config>
      <add key="http_proxy" value="http://localhost:3128" />
    </config>
 </configuration>

I added this to my Mono /etc/mono/[2.0,4.0,4.5]/machine.config file

<configuration>
  <system.net>
    <defaultProxy>
       <proxy proxyadress="http://localhost:3128" />
    </defaultProxy>
  </system.net>
</configuration>

However, this didn't have any effect. I wasn't able to run mozroots either, but I circumvented that by downloading the file and importing it manually with the file option. I think this might be related.

Mono will look for a no_proxy or NO_PROXY environment variable to generate the bypass list for a proxy.

So it would be worth checking that environment variable to see if it is using *.intranet and causing the exception

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM