在 Visual Studio 2010 中的另一个项目中引用 javascript 组件

发布于 2025-01-07 23:25:22 字数 411 浏览 0 评论 0原文

我目前正在使用 Visual Studio 10 在 Ext JS 和 ASP.NET 中开发多个 Web 项目。在此过程中,我开发了多个 javascript GUI 组件,其中一些组件在多个 Web 项目中使用。现在,当我对这些组件之一进行任何更改时,我希望它们自动出现在它们所使用的所有项目中。我也非常希望能够将这些组件放在各自的项目/解决方案中。

当构建使用组件 A 和 B 的主 ASP.NET Web 应用程序时,必须将它们的 javascript 代码复制到 Web 应用程序的输出文件夹中。

使用 C# 程序集执行此类操作没有问题 - 您只需引用所需的 DLL 即可。但令我惊讶的是,我无法找到一种方法来使用 javascript 代码(或者更一般地说,使用任何类型的静态文件)执行类似的操作!

以前有人处理过这个问题并找到了可行的解决方案吗?

I'm currently developing several web projects in Ext JS and ASP.NET using Visual Studio 10. During that process, I have developed several javascript GUI components, some of which I use in more than one web project. Now, when I make any changes to one of these components, I would like them to automatically appear in all of the projects they are used in. I also would very much like to be able to have these components in their own respective projects / solutions.

When building my main ASP.NET web application which uses my components A and B, their javascript code would then have to be copied into the web application's output folder.

It's no problem to do such things with C# assemblies - you can just reference the needed DLLs. But it amazes me that I'm not being able to find a way to do something similar with javascript code (or, more general, with any sort of static files)!

Has anyone dealt with this problem before and found a viable solution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牵你手 2025-01-14 23:25:22

我也想知道同样的事情。

您可以跨解决方案共享项目(包括由 TFS 控制的解决方案,尽管我认为这存在限制)。我已经读过有关静态文件(如脚本)的工作原理,但我还没有抽出时间来尝试它。这似乎并不适合所有情况。 此帖子讨论如何“添加为链接”,这可能有用。

我最近为我的 JavaScript/CSS 库设置了一个单独的 VS 解决方案,具有完整的源代码和构建/缩小过程。最终输出已“编译”并准备就绪。我还为每个组件和文档构建了示例页面。这些示例也可以作为很好的测试,因为我可以轻松地测试数十种不同场景中的正确行为。

编写一个脚本(甚至是一个FileSystemMonitor,如果你想变得更奇特)来将这些最终文件复制到其他项目目录中是很容易的。自动复制并不总是正确的答案,因为您可能希望使用不同版本的 JS 组件获得不同的解决方案。手动复制并不是那么糟糕,因为您通常只在发现并修复错误或部署新版本时才执行此操作。

我会对其他人在做什么感兴趣。

I have wondered the same thing.

You can share projects across solutions (including those controlled by TFS, although I imagine there are limitations to this). I've read about this working for static files (like script) but I haven't gotten around to trying it. It doesn't seem ideal for all cases. This thread discusses how to "add as link", which might be useful.

I've recently set up a separate VS solution just for my JavaScript/CSS libraries with full source and a build/minification process. The final output is "compiled" and ready to go. I have also built out sample pages for each component and documentation. These samples serve also serve as great tests, because I can easily test for correct behavior in dozens of different scenarios.

It would be easy to write a script (or even a FileSystemMonitor, if you wanted to be fancy) to copy these final files into other project directories. Automatic copying won't always be the right answer, because you may want to have different solutions using different versions of your JS components. Manually copying isn't so bad, because you are usually only doing it when you have found and fixed a bug, or you are deploying a new version.

I would be interested in what other people are doing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文