将 Microsoft Ajax Minifier 与 Web 安装项目结合使用源代码控制
我刚刚开始研究 Microsoft Ajax Minifer 4.0 与 Visual Studio 2008 一起使用我正在开发的网络应用程序。事实证明,将其挂接到 .csproj 文件中非常容易,因此它为所有脚本生成 .min.js 文件,但是我对如何将其与 Web 设置项目集成感到困惑。源代码控制。
本质上,我想做的是将生成的 .min.js 文件包含在 Web 安装项目中,而不将它们包含在源代码管理中,因为:
- 在执行构建之前必须检查它们是一种痛苦(压缩器无法修改它们)如果他们没有签出)。
- 由于它们是作为“构建工件”创建的,因此将它们存储在源代码控制下似乎是错误。
到目前为止,我遇到的唯一选择是通过右键单击 Web 安装项目并选择“添加 > 文件”,然后将相关的 .min.js 文件明确包含在安装项目中文件夹层次结构在“目标计算机上的文件系统”中重复,以便我可以强制文件到正确的位置。这既不优雅也不简单/健壮,因为:
- 它需要我手动将每个缩小的 js 文件手动添加到 Web 设置项目
- 中在 Web 应用程序项目和 Web 设置项目中维护相关目录结构的副本
- 记住添加任何新的 js 文件缩小版本到 Web 安装项目
有更好的方法吗?
I've just started investigating the Microsoft Ajax Minifer 4.0 for use with a Visual Studio 2008 Web Application I work on. It's proven easy enough to hook it into the .csproj file so it produced .min.js files for all scripts, however I'm stumped as to how to integrate this with the Web Setup project & Source Control.
Essentially what I want to do is have the resultant .min.js files included in the Web Setup project without having them included in Source Control because:
- Having to check them out prior to the build being executing is a pain (the minifier cannot modify them if they're not checked out).
- As they're created as a "build artifact" it just seems wrong to have them stored under source control.
The only option I've managed to come across so far is to explicitly include the .min.js files as part of the Setup project by right clicking on the Web Setup project and choosing "Add > File", and then having the relevant folder hierarchy duplicated in "File System on Target Machine" so that I can force the file to the correct location. This is neither elegant or simple/robust as:
- It requires me to manually add every minified js file to the Web Setup project by hand
- Maintain a copy of the relevant directory structure in both the Web Application project and the Web Setup project
- Remember to add any new js files minified versions to the Web Setup project
Is there a better way of doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终选择的解决方案是在我的项目中包含 minifier DLL 并创建一个处理程序 (.ashx),我已将其替换为对 .js 文件的所有引用,因此:
替换为
我的
web.config
文件,允许我确定脚本文件是否被压缩。The solution I eventually opted for was to include the minifier DLL in my project and create a handler (.ashx) that I've replaced all references to .js files with, so:
Is replaced with
I have a configuration setting in my
web.config
file that allows me to determine whether script files are minifed or not.来源: Microsoft
根据我的理解,这意味着不要将 -min 文件添加到项目,就是这样。当 IIS 构建应用程序时,它将自动创建文件。我认为您必须在 Web 服务器上安装 Microsoft Minifier 4.0。
source : Microsoft
From my understanding, this means do not add the -min files to the project, that's it. When IIS will build the app, it will create the files automatically. I think you must have Microsoft Minifier 4.0 to be installed on the web server tho.