将 OpenWrap 与 Scope 结合使用

发布于 2024-12-18 13:48:11 字数 1388 浏览 1 评论 0原文

我可能不完全理解关于范围界定的 wiki 文章,所以请原谅我听起来很愚蠢。

简介:
我有一个包含 40 多个项目的解决方案 (ABC.sln),并且正在尝试实施 OpenWrap 进行包管理。 因此,我在解决方案的根文件夹中执行了以下操作:

o init-wrap -all

效果很好:我现在在解决方案的根文件夹中有一个名为 SLN.wrapdesc 的文件。子文件夹中的所有 .csproj 文件都包含 OpenWrap 目标行。
然后,我继续将不同的包装添加到解决方案中:

o add-wrap -Name xxx

再次,这工作得很好:我在包装文件夹中有一些包装,并且从项目中删除旧引用后构建不会中断。

问题:
包装的所有内容都将用于所有项目,即使是那些不需要它的项目。我希望能够指定哪些包装去哪里,例如 AjaxControlToolkit 只进入 Web 项目。

我尝试过的
首先,我从wrapdesc 中删除了AjaxControlToolkit:

o remove-wrap AjaxControlToolkit

这会导致构建中断(如预期)。然后我尝试了以下操作:
1.尝试将换行添加回一个范围:

o add-wrap -Name AjaxControlToolkit -scope webproject

这只是将换行放回到换行文件夹中。然后,我将 customscope 添加到项目文件中,但构建仍然失败。
2。尝试手动将名为 ABC.webproject.wrapdesc 的文件添加到根文件夹。当我尝试打开解决方案时,这会导致以下错误:

The "exists" function only accepts a scalar value, but its argument "@(_WrapFile->'%(FullPath)')" evaluates to "D:\Projects\ABC.webproject.wrapdesc;D:\Projects\ABC.wrapdesc" which is not a scalar value.

我猜它不喜欢 2 个wrappesc 文件。这很奇怪,因为维基说“...您可以在默认描述符旁边添加第二个描述符...”

所以现在我陷入困境。有人有什么想法吗?

I may not fully understand the wiki article on scoping, so forgive me if this sounds dumb.

Intro:

I have a solution (ABC.sln) with over 40 projects and am trying to implement OpenWrap for package management.
So I did the following in the solution's root folder:

o init-wrap -all

That worked fine: I now have a file called SLN.wrapdesc in the solution's root folder. All of the .csproj files in the subfolders contain the OpenWrap targets line.
I then proceded to add the different wraps to the solution with:

o add-wrap -Name xxx

Again, this worked fine: I have some wraps in the wraps folder, and the build doesn't break after removing the old references from the projects.

Problem:
All of the contents of the wraps are going to all of the projects, even for those that don't need it. I would like to be able to specify which wraps go where, eg AjaxControlToolkit only goes into web projects.

What I tried

First, I removed the AjaxControlToolkit from the wrapdesc:

o remove-wrap AjaxControlToolkit

This causes the build to break (as expected). Then I tried the following:

1. Try to add the wrap back with a scope:

o add-wrap -Name AjaxControlToolkit -scope webproject

This simply puts the wrap back in the wraps folder. I then added <OpenWrap-Scope>customscope</OpenWrap-Scope> to the project file, but the build still broke.

2. Try and manually add a file called ABC.webproject.wrapdesc to the root folder. This causes the following error when I try to open the solution:

The "exists" function only accepts a scalar value, but its argument "@(_WrapFile->'%(FullPath)')" evaluates to "D:\Projects\ABC.webproject.wrapdesc;D:\Projects\ABC.wrapdesc" which is not a scalar value.

I guess it doesn't like 2 wrapdesc files. That is strange because the wiki says "...you can add a second descriptor alongside your default descriptor..."

So now I'm stuck. Anyone have any ideas?

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

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

发布评论

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

评论(1

甜扑 2024-12-25 13:48:11

per-msbuild 文件确实不是推荐的管理依赖项的方法。按项目执行此操作并不完全是 OpenWrap 背后的设计理念,因此该系统并未针对这些场景进行充分优化。

如果您不需要这些程序集中的某些内容,那么解决该问题的最简单方法就是不使用这些包中的任何代码,从而不使用引用。这很容易解决问题,因为如果没有添加代码,则不会加载任何内容(甚至不需要在磁盘上)。

也就是说,add-wrap -scope newscope 将创建一个额外的 .wrapdesc 文件,通过独立于原始 myProject.wrapdesc 创建 myProject.newscope.wrapdesc 文件,该文件将新的依赖项添加到新范围。

如果您确实想为每个项目执行此操作,您是否尝试过使用基于约定的范围?类似于:

directory-structure: src\*{scope: Web=WebProjects}*

将获取名称中包含 Web 的 src 子文件夹中的任何项目,并将它们分配给 WebProjects 范围。

我知道到目前为止,它对我的​​项目运行良好,尽管您必须重新启动 VS,因为它会积极缓存某些文件并且不会看到更改。

自定义 msbuild 文件本身尚未经过充分测试(并且 wiki 条目很大程度上是设计规范而不是最终文档,并非所有内容都是以这种方式构建的),因此它可能会也可能不会。如果您可以在 http://github.com/openrasta/openwrap/ 上打开错误票,我们很乐意查看问题

The per-msbuild file is really not a recommended approach to managing dependencies. Doing it per project is not quite the design philosophy behind OpenWrap, so the system is not quite optimized for those scenarios.

If you don't need something from those assemblies then the easiest way to solve it is to not use the references by not using any code from those packages. This solves the problem very easily as nothing will get loaded (or even need to be on disk) if no code has been added to it.

That said, add-wrap -scope newscope will create an additional .wrapdesc file that will add the new dependency to the new scope, by creating a myProject.newscope.wrapdesc file independently of the original myProject.wrapdesc.

If you do want to do this per-project, have you tried using the convention-based scoping? Something like:

directory-structure: src\*{scope: Web=WebProjects}*

Would take any project in a folder child of src containing Web in the name and assign those to the WebProjects scope.

I know that one has worked fine for my projects so far, although you do have to restart VS as it aggressively caches certain files and will not see the change.

Customizing the msbuild file itself is not fully tested (and the wiki entry was very much a design spec rather than final documentation, not all of it has been built that way) so it may or may not work. Happy to take a look if you can open a bug ticket on http://github.com/openrasta/openwrap/issues

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