MSBuild:如何强制 ProjectReference 在其他地方搜索程序集?
我们有大量的 Visual Studio 解决方案,其中包含相同的共享 15 个项目,并且大多数解决方案仅在 Web 应用程序方面有所不同。
我试图将所有内容合并到一个构建中,该构建仅构建一次共享项目,然后让 Web 应用程序项目引用输出共享程序集。
我发现,由于 Web 项目通过
但这仅在 Web 项目通过
We have a large number of Visual Studio Solutions that contain the same shared 15 projects, and most solutions only differ by a web application.
I'm trying to consolidate everything into a single build that builds the shared projects only once, then have the web application projects reference the output shared assemblies.
I'm finding that, since the web project points to the shared projects via the <ProjectReference> element, I can't tell it to look elsewhere for an assembly inside of my custom build project. I would like to use something similar to:
<MSBuild Projects="@(Solutions)" Targets="Rebuild" Properties="ReferencePath=$(MyReferencePathFolder)">
but that will only work if the web project references the dll of the shared assembly through a <Reference> element. It seems that if it can't find what's pointed at in <ProjectReference>, it doesn't try to look in any ReferencePath folder. It just gives up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要考虑从众所周知的位置引用 15 个共享程序集。
您可以创建一个包含 15 个项目的解决方案,并将输出复制到特定文件夹。 然后,您可以更改 Web 应用程序项目以引用程序集,而不是共享项目。
使用此方法会失去从 Web 应用程序解决方案自动重建共享项目的能力。 如果您希望在处理 Web 应用程序解决方案之一时自动重建 15 个程序集,您可以在 Web 应用程序解决方案中添加预构建步骤来构建新的共享项目解决方案。
You may want to consider referencing the 15 shared assemblies from a well known location.
You could create a solution that contains the 15 projects and copies the output to a specific folder. Then you can change your web app projects to reference the assemblies, and not the shared projects.
What you lose with this method is the ability to automatically rebuild your shared projects from a web app solution. If you want to automatically rebuild the 15 assemblies when working on one of the web app solutions, you could add a pre-build step in your web app solutions to build your new shared project solution.