我有一个ASP.Net 5 MVC 6项目,它使用了几个非DNX类库。这些库通过dnu包装包装,所有工作都可以在IIS Express或自托管应用程序上找到。但是在IIS 8上它显示错误
无法解决目标框架的以下依赖关系 ' DNX,版本= V4.5.1&#39 ;: 我的项目清单
当前运行时目标框架:' DNX,版本= v4.5.1(dnx451)' 版本:1.0.0-beta7-15532 类型:CLR 架构:x64 操作系统名称:Windows 操作系统版本:6.3.9600.0
如果我使用dnx 4.6(我只是降级以查看它是否适用于4.5.1),同样的错误。
但是可以在以下位置找到lib:approot \ packages \ 使用正确的nuget包结构(dnu发布打包)
那么我如何帮助IIS找到我的库?
重现的步骤:
使用2个项目创建解决方案:新的ASP.Net MVC应用程序和通常的类库(不是包)
通过dnu wrap
来自MVC的参考类库
发布Web应用程序(如果从Visual Studio发布不起作用,请使用dnu publish --runtime active)
在IIS中创建网站并将其指向已发布的网络应用的wwwroot文件夹
更新 原来这个问题不是在IIS本身,而是在DNX中。如果我发布网站然后通过Microsoft.AspNet.Server.WebListener运行它,我会得到同样的错误。看起来dnu publish与包装项目无法正常工作。
但是,运行Windows服务时不是这种情况。我有一个引用相同库的控制台应用程序(包),我用--no-source发布它,然后通过sc.exe将它安装为windows服务,它都按预期工作。
答案 0 :(得分:3)
My issue was that in project.json I had references with no library version, just an empty strings. It works under Visual Studio, but not when running without VS. I had such references because in RC I couln't add reference vie context menu, so I added it manually and it worked. So here are the step on how to set up web site to run under IIS:
1) Wrap you non-DNX projects with "dnu wrap" command
2) Add reference from DNX project to you non-DNX project and check that you have a correct version in project.json (should be same version as in wrap\yourproject\project.json). Here is an example:
"frameworks": {
"dnx46": {
"dependencies": {
"MyLib": "1.0.0-*"
}
}
3) Publish your website with dnu publish
dnu publish .\src\Web --out <outputfolder>
4) Publish again with runtime parameter. This time runtime is copied to the output folder. But wwwroot folder is not created this time, good we have run publish in step 3 already ;-). You can change order of steps 3 and 4
dnu publish .\src\Web --out <outputfolder> --runtime dnx-clr-win-x64.1.0.0-beta7
5) Go to outputfolder\wwwroot\web.config
and type values for 2 parameters in appsettings: dnx-version and dnx-clr. Here is example:
<appSettings>
<add key="bootstrapper-version" value="1.0.0-beta7" />
<add key="runtime-path" value="..\approot\runtimes" />
<add key="dnx-version" value="1.0.0-beta7" />
<add key="dnx-clr" value="clr" />
<add key="dnx-app-base" value="..\approot\src\Web" />
</appSettings>
6) Create new web site in IIS, choose app pool with runtime .Net v4.0
7) Point your new website to outputfolder\wwwroot folder
8) Check that everything is working