I have an ASP.Net 5 MVC 6 project that uses several non-DNX class libraries. These libs are wrapped via dnu wrap, and all works find on IIS Express or self-hosted app. However on IIS 8 it shows error
Failed to resolve the following dependencies for target framework 'DNX,Version=v4.5.1': list of my projects
Current runtime target framework: 'DNX,Version=v4.5.1 (dnx451)' Version: 1.0.0-beta7-15532 Type: CLR Architecture: x64 OS Name: Windows OS Version: 6.3.9600.0
The same error if I use dnx 4.6 (I just downgraded to see if it works with 4.5.1).
However the libs can be found in the following location: approot\packages\ with correct nuget package structure (dnu publish packed them)
So how do I help IIS find my libs?
Steps to reproduce:
Create solution with 2 projects: New ASP.Net MVC application and usual class library (not package)
Wrap class library via dnu wrap
Reference class library from MVC
Publish web application (if publish from Visual Studio does not work, use dnu publish --runtime active)
Create web site in IIS and point it to the wwwroot folder of published web app
UPDATE: Turned out that the problem is not in IIS itself, but in DNX. I get the same error if I publish web site and then run it via Microsoft.AspNet.Server.WebListener. Looks like dnu publish is not working properly with wrapped projects.
However this is not the case when running Windows Service. I have a console app (package) that references the same libraries, I publish it with --no-source and then install it as windows service via sc.exe and it all works as expected.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With