ASP.NET 5:类库包中的Nuget包出现错误 [英] ASP.NET 5: Error with Nuget package in Class library Package

查看:69
本文介绍了ASP.NET 5:类库包中的Nuget包出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用VS2015社区版本和ASP.NET 5.

I start playing with VS2015 community version and ASP.NET 5.

我在解决方案中添加了一个新类库(包)作为新项目,但是无法在其中安装NuGet包.恢复后,我有一个参考(错误-请参阅错误列表)".

I have added a new class library (Package) as a new project into my solution but am unable to install a NuGet package in it. After the restoring, I have a "Reference (Errors - see Error List)".

如果我将基本库类(.dll)作为新项目添加到解决方案中,并尝试安装相同的NuGet程序包,则它的工作方式将像往常一样漂亮.

If i add a basic Library Class (.dll) as a new project into my solution and try to install the same NuGet package, it works beautifully as it used to.

也许,我误会了这个新的类库程序包的工作方式,并且试图滥用它...

Perhaps, I am misunderstanding how this new class library package works and I am trying to misuse it...

感谢您的帮助.

------------------------------------------------------------------编辑1 -----------------------------------------------------------Project.json:在这种情况下,警告标志位于EF软件包上:

--------------------------------------------------------------EDIT 1----------------------------------------------------------- Project.json: The warning flag in that case is on the EF package:

{
    "version": "1.0.0-*",
    "description": "testFinal Class Library",
    "authors": [ "SylvainC" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
        "System.Collections": "4.0.10-beta-23019",
        "System.Linq": "4.0.0-beta-23019",
        "System.Threading": "4.0.10-beta-23019",
        "System.Runtime": "4.0.10-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019",
        "EntityFramework": "6.1.3"
    },

    "frameworks": {
        "dotnet": { }
    }
}

--------------------------------------------------------更新至beta8后编辑1之二----------------------------

----------------------------------------------------EDIT 1 bis after update to beta8--------------------------

{
  "version": "1.0.0-*",
  "description": "ClassLibrary5 Class Library",
  "authors": [ "SylvainC" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {
    "dnx451": { }
  },
  "dependencies": {
    "EntityFramework": "6.1.3"
  }
}

------------------------------------------------------------------编辑2 -----------------------------------------------------------

--------------------------------------------------------------EDIT 2-----------------------------------------------------------

升级dnvm(dvnm升级)后,我能够运行"dnu restore"命令,但出现以下错误:

After upgrading the dnvm (dvnm upgrade), i was able to run the "dnu restore" command but got the following error:

>dnu restore
Microsoft .NET Development Utility Clr-x86-1.0.0-beta8-15858

  GET https://www.nuget.org/api/v2/
  GET https://www.myget.org/F/aspnetmaster/api/v2/
Restoring packages for D:\testFinal\project.json
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection'
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Reflection'
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization'
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Globalization'
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='EntityFramework'
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='EntityFramework'
Warning: FindPackagesById: System.Globalization
  An error occurred while sending the request.
Warning: FindPackagesById: System.Globalization
  An error occurred while sending the request.
Warning: FindPackagesById: System.Reflection
  An error occurred while sending the request.
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Globalization'
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Reflection'
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization'
Warning: FindPackagesById: System.Reflection
  An error occurred while sending the request.
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection'
Warning: FindPackagesById: EntityFramework
  An error occurred while sending the request.
Warning: FindPackagesById: EntityFramework
  An error occurred while sending the request.
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='EntityFramework'
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='EntityFramework'
Warning: FindPackagesById: System.Reflection
  An error occurred while sending the request.
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Reflection'
Warning: FindPackagesById: System.Globalization
  An error occurred while sending the request.
Warning: FindPackagesById: System.Globalization
  An error occurred while sending the request.
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Globalization'
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='System.Globalization'
Warning: FindPackagesById: System.Reflection
  An error occurred while sending the request.
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='System.Reflection'
Warning: FindPackagesById: EntityFramework
  An error occurred while sending the request.
  GET https://www.nuget.org/api/v2/FindPackagesById()?id='EntityFramework'
Warning: FindPackagesById: EntityFramework
  An error occurred while sending the request.
  GET https://www.myget.org/F/aspnetmaster/api/v2/FindPackagesById()?id='EntityFramework'
Error: FindPackagesById: System.Reflection
  An error occurred while sending the request.
----------
Error: FindPackagesById: System.Globalization
  An error occurred while sending the request.
Error: FindPackagesById: System.Globalization
  An error occurred while sending the request.
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:8888
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---

-------------------------------------------------编辑3最后的错误和提要------------------------------

---------------------------------------------EDIT 3 with final error and feeds------------------------------

Restore failed
An error occurred while sending the request.
NuGet Config files used:
    C:\Users\sylvainc\AppData\Roaming\NuGet\nuget.config
Feeds used:
    https://www.nuget.org/api/v2/
    https://www.myget.org/F/aspnetmaster/api/v2/

西尔万

推荐答案

这似乎是一个代理问题,给了我无法建立连接,因为目标计算机主动拒绝了127.0.0.1:8888错误.

It seems to be a proxy issue giving me this No connection could be made because the target machine actively refused it 127.0.0.1:8888 error.

通过Fiddler进行跟踪,我发现在打开Fiddler之后,还原过程和添加新的Nuget包都可以正常工作.这种情况与为什么只有在我打开Fiddler的情况下才能在ASP.NET中调用API?或在以下位置:

Tracking it down with Fiddler, I discovered that after opening Fiddler, the restore process and adding new Nuget packages was working fine. A situation quite similar to this post Why calling API in ASP.NET works only if I have Fiddler open? or here: http://www.telerik.com/blogs/help!-running-fiddler-fixes-my-app-.

我还尝试将dnx.exe.config创建为 C:\ Users \ sylvainc \ .dnx \ runtimes \ dnx-clr-win-x86.1.0.0-beta8 \ bin http://github.com/aspnet/dnx/issues/451 中建议.不幸的是,它似乎不适用于beta8版本.

I also tried to create a dnx.exe.config into C:\Users\sylvainc\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta8\bin as suggested in http://github.com/aspnet/dnx/issues/451. Unfortunately it seems not to work with the beta8 version.

我的第一个解决方法是按照以下建议使用HTTP协议访问我的NuGet软件包:

My first workaround solution was to use the HTTP protocol to access my NuGet packages as suggested here: Visual Studio 2015 - Can't sign in, Use NuGet, etc. behind corporate proxy.

我的最终解决方案是使用管理员记事本+在 C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Config 中编辑machine.config文件,以获取提琴手的默认代理定义并使用系统定义:

My final solution was to edit the machine.config file as administrator with Notepad+ in C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config to get ride of the fiddler default proxy definition and to use the system ones:

<!--<system.net>
         <defaultProxy enabled="true" useDefaultCredentials="true">
         <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false"/>
         </defaultProxy>
     </system.net>-->
<system.net>
    <defaultProxy useDefaultCredentials="true" enabled="true">
    <proxy usesystemdefault="True"/>
    </defaultProxy>
</system.net>

现在ASP.Net 5可以正常工作,我现在甚至可以使我的intellisense正常工作,而使用其他代理定义则不是这种情况...

Now ASP.Net 5 works fine, I even have my intellisense working properly now which was not the case before with the other proxy definition...

谢谢

西尔万

这篇关于ASP.NET 5:类库包中的Nuget包出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆