简体   繁体   English

VS2013:发布在项目外部文件上创建的缩小包

[英]VS2013: Publish minified bundle created on files outside of the project

I use Visual Studio 2013 and .NET 4.5 for an MVC project. 我将Visual Studio 2013和.NET 4.5用于MVC项目。

I've learning to use AngularJS via several videos on Pluralsight and one of them walks through the process of using Grunt to clean the output directory, then use ngmin to min-safe the Javascript files. 我已经通过Pluralsight上的多个视频学习了如何使用AngularJS,其中一个视频逐步介绍了使用Grunt清理输出目录,然后使用ngmin最小化Javascript文件的过程。

My process is using a gruntfile.js to clean and run ngmin against the javascript files in my solution, then put them in a directory called app_built. 我的过程是使用gruntfile.js清理并针对解决方案中的javascript文件运行ngmin,然后将其放在名为app_built的目录中。 This is executed via a batch file in the pre-build for the project and then I include it via a ScriptBundle with IncludeDirectory pointing to the app_built directory. 这是通过项目的预构建中的批处理文件执行的,然后我通过ScriptBundle将其包含,其中IncludeDirectory指向app_built目录。 My intent is to use the Bundling features of .NET 4.5 to do the rest of the minification and concatenation of the Javascript after all the files have been min-safed via Grunt. 我的意图是在通过Grunt对所有文件进行最小安全保护之后,使用.NET 4.5的捆绑功能来完成Javascript的其余部分的缩小和串联。

I specify the path to the min-safed files with the following: 我使用以下命令指定最小安全文件的路径:

bundles.Add(new ScriptBundle("~/bundles/minSafed")
  .IncludeDirectory("~/app_built/", "*.js", true));

If I run this on my local machine, it runs fine without a hitch. 如果我在本地计算机上运行此程序,它将正常运行。 The Javascript is minified and bundled as I'd expect and the resulting web application runs fine as well. 正如我所期望的,JavaScript被精简和捆绑在一起,并且最终的Web应用程序也运行良好。

If I publish the website to a remote server, I get a server error that the "Directory does not exist. Parameter name: directoryVirtualPath". 如果将网站发布到远程服务器,则会收到服务器错误,指出“目录不存在。参数名称:directoryVirtualPath”。 I assume this error is saying that it's unable to find the directory populated with my many *.js files. 我以为这个错误是在说我找不到许多* .js文件填充的目录。 I also assume this is because they weren't published since they aren't part of the solution, even though the folder they reside in is a part of the solution (it's just empty within the solution explorer in Visual Studio). 我还认为这是因为它们不是解决方案的一部分,所以它们没有发布,即使它们所在的文件夹解决方案的一部分(在Visual Studio的解决方案资源管理器中只是空的)。

If my assumption is correct, what can I do to add these files to my solution so they'll be published with the rest of my web application with minimal effort on my end each time? 如果我的假设是正确的,我该怎么做才能将这些文件添加到我的解决方案中,以使它们与我的Web应用程序的其余部分一起发布,而在每次结束时都花费最少的精力?

And if I'm incorrect in the assumption, what I can I do to resolve this otherwise? 如果我的假设不正确,我该如何解决呢?

Thanks! 谢谢!

I never did find a great way of going about this. 我从来没有找到解决这个问题的好方法。 I found information at http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx that seems related, but I was unable to make it work. 我在http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageInincludeExtraFilesOrExclusionSpecificFiles.aspx中找到了似乎相关的信息,但我无法使其工作。

Rather, since I knew the name of the outputted file, I simply created such an empty file in my project and referenced that where I needed to. 相反,因为我知道输出文件的名称,所以我只是在项目中创建了一个空文件,并在需要的地方引用了该文件。 I then had the pre-build task replace the contents of that file with the externally minified version and it would be packaged with the project as necessary, so it works well enough. 然后,我进行了预构建任务,用外部的最小版本替换了该文件的内容,并根据需要将其与项目打包在一起,因此效果很好。

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

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