简体   繁体   English

将MVC项目编译为单个DLL?

[英]Compile MVC project to a single DLL?

Just wondering if it's possible really. 只是想知道是否真的可能。 I have a large website, with hundreds of JS and HTML files. 我有一个大型网站,其中包含数百个JS和HTML文件。

Is it possible to compile these down into a single DLL, so when deployed to customers web servers they don't see or have access to the code? 是否有可能将它们编译成单个DLL,因此当部署到客户Web服务器时,他们看不到或无法访问代码?

I have never tried, but theoretically it is possible to achieve that. 我从未尝试过,但理论上有可能实现这一目标。

HTML - compile (I assume you use *.cshtml) Set <MvcBuildViews>true</MvcBuildViews> in the <PropertyGroup> element of your .csproj file. <MvcBuildViews>true</MvcBuildViews>编译(我假设您使用* .cshtml)在.csproj文件的<PropertyGroup>元素中设置<MvcBuildViews>true</MvcBuildViews>

JS, you will have to ember js files as resources, use ScriptManager to load it JS,您必须将js文件作为资源嵌入,使用ScriptManager加载它

CSS - hack it, with same methods as js, but using Add CSS File in DLL (Class Library) CSS-使用与js相同的方法对其进行破解,但在DLL中使用添加CSS文件(类库)

Even if you minify, obfuscate, compile and ship it as dll, I will be able to see html/css/js with developer tools. 即使您将其缩小,混淆,编译并以dll形式发布,我也可以使用开发人员工具查看html / css / js。 And honestly none of it make sense, horrible debugging, no caching. 老实说,这些都没有道理,可怕的调试,没有缓存。

you actually can, 你实际上可以

ember your js and css files (view remigijus answer). 嵌入您的js和CSS文件(查看remigijus答案)。 When you publish, in the configure part of the settings tab (see capture below), be sure to uncheck "allow precompiled site to be updatable" <--- will compile the cshtml "chose merge page and control in a single assembly" 发布时,请确保在“设置”选项卡的“配置”部分(请参见下面的截图)中,取消选中“允许可预编译的站点可更新” <---将编译cshtml“选择合并页面并在单个程序集中进行控制”

在此处输入图片说明

but i raise the same warnings than your other answers, it's useless and counterproductive. 但是我提出的警告与您的其他回答相同,这毫无用处且适得其反。 Keep in mind that anyone can decompile a .net assembly anyway 请记住, 任何人都可以反编译.net程序集

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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