内容文件,的NuGet是非常非常慢 [英] Content-files with NuGet are very very slow

查看:824
本文介绍了内容文件,的NuGet是非常非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由多个站点共享一个共同的ASP.NET Web应用程序。我用的NuGet打包这个共同的Web应用程序,并在多个网站发布。依照该思路:依赖于一个共同的基础应用多个ASP.NET Web应用程序

这样,我结束了一些问题。当更新了新版本,成为的NuGet的很慢。这是因为它包含800内容文件。不知怎么的NuGet已花费大约1〜2秒钟,它需要卸载的每个内容文件,大约有 25分作为卸载和5分钟的安装结束了。特别是随着一个TFS结合。综观的NuGet的源 - code我想通的Visual Studio,其中的NuGet是谈话的API是瓶颈。造成的的Visual Studio 以峰值周围的CPU使用率的 100%的全过程。

所以我想,如果Visual Studio是慢,也许我能做到这一点离不开它。令我失望的NuGet命令行(如果没有的Visual Studio运行)只下载一个包,解压它。它不会因为更新的事实:一些PowerShell的脚本,可以参考DTE对象......(虽然我不)项目文件。

现在我想知道:什么是我的选择。


  1. 在项目文件添加内容的项目做一些XML的魔力?什么是这样做的缺点?是否已有的工具吗?

  2. 做一些魔术构建脚本?

  3. 扔掉内容的文件,从包装中取出,并使用像鲍尔什么的另一种工具?怎么可以这样被集成到这个项目?因为最终我希望看到的内容的文件,我有。

  4. 不使用的NuGet在所有但别的东西......? OpenWrap?喇叭? (似乎不再有效)或者,也许没有包管理器呢?<​​/ li>

请帮我找到最好的解决办法:)

这让我很沮丧是执行的NuGet更新时的另一件事,它卸载,然后由安装。为什么,如果版本之间的变化可能是最小的?


解决方案

一种选择是,而不是增加800内容文件,你可以将它们嵌入在你的共享资源库。

然后使用类似 EmbeddedResourceVirtualPathProvider https://开头github上。 COM / mcintyre321 / EmbeddedResourceVirtualPathProvider 来为他们服务的。

这样的NuGet是简单地替换.dll文件,而不是800个独立的文件。

有很多文章在网上关于如何使用的VirtualPathProvider

修改:有关性能问题

解决方案看起来比较简单,所以我只是尝试一下,看看表现尚可。这种做法的好处是,你不必做任何特殊的路径与您的Web应用程序。

下面是步骤,你需要做的:


  1. 在您的资源库,内容文件设置为嵌入的资源。你可以做到这一点很快就被打开了的 .csproj的的文件在文本编辑器和更换&lt;内容&LT; EmbeddedResource

  2. 要你的资源库中添加一个引用您的Web应用程序。

  3. EmbeddedResourceVirtualPathProvider 的NuGet包添加到您的Web应用程序

  4. 注册虚拟路径提供。下面是使用注册一个例子 AppInitialize()存储在 APP_ code 文件夹中。

命名空间TestWebProject.App_ code
{
    公共类RegisterVirtualPathProvider
    {
        公共静态无效AppInitialize()
        {
            HostingEnvironment.RegisterVirtualPathProvider(新EmbeddedResourceVirtualPathProvider.Vpp()
            {
                {typeof运算(标记).Assembly,@.. \\ TestResourceLibrary},            });
        }
    }
}

I have a common ASP.NET web application that is shared by multiple sites. I used NuGet to package this common web application and distribute it over the multiple sites. Following this idea: Multiple ASP.NET web applications depending on a common base application.

By doing this, I end up with some issues. When updating for a new version, NuGet becomes really slow. This is because of the 800 content-files it contains. Somehow NuGet has to take around 1~2 seconds for each content-file it needs to uninstall, ending up with approximately 25 minutes for uninstall and 5 minutes for install . Especially with a TFS-binding. Looking at the source-code of NuGet I figured that the API of Visual Studio where NuGet is talking to is the bottleneck. Causing Visual Studio to peak around 100% of CPU-usage the whole process.

So I thought, if Visual Studio is that slow, maybe I can do it without it. To my disappointment the NuGet commandline (that runs without Visual Studio) only downloads a package and unzips it. It won't update the project-file due the fact that some Powershell-scripts could reference to the DTE-object... ( although I don't).

Now I'm wondering: what are my options?

  1. Doing some XML-magic on the project-file to add content-items? What are the drawbacks of doing this? Is there already a tool for this?
  2. Doing some magic with build scripts?
  3. Throw away the content-files out of the package and use another tool like Bower or something? How may this be integrated into the project? Because eventually I want to see the content-files I have.
  4. Not using NuGet at all but something else ...? OpenWrap? Horn? (seems to no longer be active) Or maybe no package manager at all?

Please help me find the best solution :)

.

One other thing that frustrates me is when performing a NuGet update, it does an uninstall followed by an install. Why, if the changes between versions could be minimal?

解决方案

One option is that instead of adding 800 content files, you can embed them as resources in your shared library.

Then use something like EmbeddedResourceVirtualPathProvider https://github.com/mcintyre321/EmbeddedResourceVirtualPathProvider to serve them up.

That way NuGet is simply replacing the .dll instead of 800 individual files.

There are plenty of articles online about how to use VirtualPathProvider.

EDIT: Questions about performance

The solution seems relatively simple, so I would just try it and see if the performance is acceptable. The nice thing is that you don't have to do anything special with paths in your web app.

Here are the steps you need to do:

  1. In your resource library, set the content files to embedded resource. You can do that quickly by opening up the .csproj file in a text editor and replacing <Content with <EmbeddedResource.
  2. Add a reference to your resource library to your web app.
  3. Add the EmbeddedResourceVirtualPathProvider NuGet package to your web app
  4. Register the virtual path provider. Here's an example to register using AppInitialize() stored in the App_Code folder.

namespace TestWebProject.App_Code
{
    public class RegisterVirtualPathProvider
    {
        public static void AppInitialize()
        {
            HostingEnvironment.RegisterVirtualPathProvider(new EmbeddedResourceVirtualPathProvider.Vpp()
            {
                {typeof (Marker).Assembly, @"..\TestResourceLibrary"},

            });
        }
    }
}

这篇关于内容文件,的NuGet是非常非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆