有没有办法来改变.NET MVC bin目录的位置? [英] Is there a way to change .net mvc bin dir location?
问题描述
我有一个比较规范和简单的MVC4网站。
I have a fairly standard and simple MVC4 website.
在根目录,我们有:斌,内容,脚本的意见。使用默认设置项目的DLL,让我们把它称为web.dll和所有必要的临时演员走在bin目录。
In root dir we have: bin, content, scripts, views. Using default settings the project's DLL, let's call it "web.dll" and all the necessary extras go in the bin dir.
不知何故,ASP.NET开发服务器IIS7.5和都知道托管网站时认准web.dll中的bin文件夹,如果它不存在他们扔的错误:无法加载类型CVD。 Web.MvcApplication'。该错误的标准解决方案是直接建成bin文件夹,它不适合我,因为...
Somehow, ASP.NET dev server and IIS7.5 both know to look for "web.dll" in the bin folder when hosting the site, and if it's not there they throw error: "Could not load type 'CVD.Web.MvcApplication'". The standard solution for that error is to build directly into bin folder, which doesn't work for me because...
有关调试的目的,我希望能够建立调试和放大器;分别然后释放到配置成BIN /调试和斌/释放同时部署迪尔斯,然后换一个设置无论是在IIS,web.config中,Global.asax的,或其他任何地方接是否调试或发布版本应该被加载和执行服务器
For debugging purposes, I'd like to be able to build Debug & Release configurations into into bin/Debug and bin/Release respectively and then deploy both dirs, then change a setting either in IIS, web.config, global.asax, or anywhere else to pick whether Debug or Release build should be loaded and executed by the server.
我一直没能找到如果可能的话,或者.NET的webapps有一个愚蠢的硬codeD规则说所有code必须住在bin目录。
I haven't been able to find if that's possible or if .net webapps have a silly hard-coded rule saying all code must live in the bin dir.
推荐答案
确定,所以由森雅各布提供的几个环节的帮助和一些研究,我已经想通了,这是可以做到这一切只是使用网络的.config。
OK, so with the help of few links provided by Sen Jacob and some more research I've figured out that it is possible to do it all just using web.config.
都需要我们提供新的路径,告诉组装的名字,因为我们是从违约转向远离首先:
First of all we need to provide the new path and tell the assembly name since we're steering away from defaults:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Something.Web" />
</assemblies>
</compilation>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin\debug" />
</assemblyBinding>
</runtime>
</configuration>
现在,出于某种原因,其他地方的人建议指定 privatePath
相对于bin目录(即 privatePath =调试
),但在我的情况下,它必须是相对于应用程序根目录(即如上)。也许这是在一个.NET4更改或其他配置设置我失踪,不知道;如果有人有更好的主意随意编辑/评论。
Now, for some reason everywhere else people suggest specifying privatePath
relative to bin dir (i.e. privatePath="debug"
), however in my case it had to be relative to app root (i.e. as above). Maybe it's a change in .net4 or some other configuration setting I'm missing, not sure; if someone has a better idea feel free to edit/comment.
在这个阶段,如果服务器找到该文件,并成功地加载程序集和类就会开始抱怨所有缺少引用的文件,我不得不旁边添加到&LT;添加装配=Something.Web/&GT;
:
At this stage, if the server finds the file, and successfully loads the assembly and the class it will start complaining about all the missing referenced files, which I had to add right next to <add assembly="Something.Web" />
:
<assemblies>
<add assembly="Something.Web" />
<add assembly="System.Web.Mvc" />
<add assembly="System.Web.Optimization" />
<add assembly="System.Web.Helpers" />
<add assembly="System.Web.WebPages" />
</assemblies>
从我收集到它重新编译现场启动(不知道)的组件。
From what I've gathered it re-compiles the assemblies on site startup (not sure).
来源:
1
2
<一href=\"http://stackoverflow.com/questions/2967248/removing-all-assemblies-from-compilationassemblies-in-asp-net-4-web-config\">3
这篇关于有没有办法来改变.NET MVC bin目录的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!