MSBuild 覆盖项目参考以解析为预编译程序集

发布于 2024-08-29 06:18:20 字数 539 浏览 6 评论 0原文

情况

我有大约 400 个使用项目引用的 csproj 文件。一个单独的团队希望将其中大约 3 个分叉并合并到一个独立的应用程序中。

我对 3 个感兴趣的项目进行了分支,因为单独的团队使用 diff SVN 存储库,所以我使用 svn externals 将这些项目拉入独立应用程序的文件夹中。显然,由于该团队使用不同的文件夹结构,因此项目引用不再解析。

尝试的解决方案

我认为将 msbuild 属性 ReferencePathAdditionalLibPaths 设置为指向包含所有预编译依赖项的目录将允许项目引用回退点并正确解决。但事实似乎并非如此。

问题

  • 有谁知道如何获得 项目参考查找失败 解析为预编译的dll?
  • 也许给我指出一个自动化工具 将项目引用转换为 dll 参考?
  • 或者有更好的方法来解决这个问题吗?

谢谢

Situation

I have about 400 csproj files using project references. About 3 of those a separate team wants to fork and incorporate into a standalone app.

I branched the 3 projects of interest, and because the separate team uses a diff SVN repo I used svn externals to pull in these projects into the folder of the standalone app. Obviously since this team uses a different folder structure the project references no longer resolve.

Attempted Solution

I figured setting the msbuild properties ReferencePath and AdditionalLibPaths to point to a directory with all the precompiled dependencies would allow the project references a fallback point and resolve correctly. However that doesn't appear to be the case.

Question

  • Does anybody know a way to have a
    failed projectreference look up
    resolve to the precompiled dll?
  • Perhaps point me to an automated tool
    to convert projectreferences to dll
    references?
  • Or is there a better way to solve this problem?

Thanks

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

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

发布评论

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

评论(2

懒猫 2024-09-05 06:18:20

项目引用由目标 ResolveProjectReferences 解析。它基本上在引用的项目上调用 GetTargetPath 并将其用作已解析项目程序集路径。
IIUC,您的项目文件路径在新设置中不正确,因此 GetTargetPath 将失败。

您可以通过多种方式解决此问题,例如使用目标 [1] 将旧项目文件路径映射到已解析的程序集路径,并将其添加到 FooItem [2]。或者您可以将带有“所有预编译依赖项”的目录中的所有文件添加到@(ReferencePath)。 ReferencePath 是在解析之后填充的,因此它具有所有最终路径。向其添加搜索路径不会有帮助。

  1. 并将此目标添加到 ResolveReferencesDependsOn 属性

  2. GetTargetPath 调用应将返回的路径添加到某个项目名称,用该项目名称替换 FooItem。

    >

Project references are resolved by the target - ResolveProjectReferences. It basically calls GetTargetPath on the referenced project and uses that as the resolved project assembly path.
IIUC, your project file path is not correct in the new setup, so GetTargetPath would fail.

You could solve this in many ways like have a target [1] which maps the old project file paths to the resolved assembly paths, and adds it to FooItem [2]. Or you could just add all the files from the directory with "all precompiled deps" to @(ReferencePath). ReferencePath is populated after the resolution, so it has all the final paths. Adding a search path to it won't help.

  1. And add this target to the ResolveReferencesDependsOn property

  2. The GetTargetPath call should be adding the returned paths to some item name, replace FooItem by that item name.

寒冷纷飞旳雪 2024-09-05 06:18:20

项目文件(csproj)是XML文件,如果您需要进行任何操作,您可以编写自己的工具:

Project Files (csproj) are XML Files,you can write your own tool if you require to make any manipulations:

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