[英]How to F5 deploy with add-in libraries in Visual Studio?
I maintain an application with some project references it depends on. 我维护一个应用程序,其中包含一些依赖它的项目引用。 Further on, there are some "add-in" projects in the same solution which aren't needed to compile the application, but are loaded at run-time.
此外,在同一解决方案中有一些“附加”项目不需要编译应用程序,而是在运行时加载的。 Nevertheless, the "add-in" projects are vital for the application to do its work.
但是,“附加”项目对于应用程序完成其工作至关重要。 That is, they are mandatory add-ins.
也就是说,它们是强制性加载项。
My team shall always be able to launch the application using Visual Studio, doing an incremental build as necessary, with the add-in libraries deployed to the application. 我的团队将始终能够使用Visual Studio启动应用程序,并根据需要进行增量构建,并将加载项库部署到应用程序中。
The add-in projects don't share their output directory with the application project since the add-in projects are AnyCPU, while the application is build for the x86 and x64 platforms. 外接程序项目不与应用程序项目共享其输出目录,因为外接程序项目是AnyCPU,而应用程序是针对x86和x64平台构建的。
I hesitate to simply add P2P references to the add-in projects. 我很犹豫,只是将P2P引用添加到加载项项目中。 Not having the P2P references is not only a good way to communicate the add-in character of those projects, it also helps IntelliSense to not become overwhelming.
没有P2P引用不仅是传达这些项目的附加特性的一种好方法,而且还有助于IntelliSense变得不知所措。
I tried to use P2P references with ReferenceOutputAssembly
set to false
, but this seems to not support incremental build inside Visual Studio. 我尝试将
ReferenceOutputAssembly
设置为false
来使用P2P引用 ,但这似乎不支持Visual Studio内部的增量构建。
So, in presence of the above mentioned real-world constraints, how can I provide a satisfactory F5-experience? 那么,在上述现实世界中存在的约束条件下,我如何才能提供令人满意的F5体验?
Use P2P references with ReferenceOutputAssembly
set to false
, but consider the following pit-falls: 在
ReferenceOutputAssembly
设置为false
的情况下使用P2P引用,但请考虑以下陷阱:
DisableFastUpToDateCheck
property to true
in the application project, as described in the docs . DisableFastUpToDateCheck
属性设置为true
来禁用检查,如docs中所述 。 This is likely to substantially increase build time. CopyToOutputDirectory
metadatum in the project reference in case the output directory of application and referred project coincide. CopyToOutputDirectory
元数据。 Otherwise, this brakes the Rebuild
target. Rebuild
目标。 So, in presence of the above mentioned real-world constraints, how can I provide a satisfactory F5-experience?
那么,在上述现实世界中存在的约束条件下,我如何才能提供令人满意的F5体验?
If I understand you correct, I am afraid you have entered a misunderstanding. 如果我理解您的正确,恐怕您输入了一个误解。 Using P2P references with
ReferenceOutputAssembly
set to false
, Visual Studio/MSBuild will not copy that reference library to the output of reference project, but the referenced project will still be compiled. 在
ReferenceOutputAssembly
设置为false
使用P2P引用,Visual Studio / MSBuild不会将该引用库复制到引用项目的输出,但是仍将编译引用的项目。
If you do not want to compile those "add-in" projects in the same solution, but load them at run-time, you can reference the .dll
file directly of those "add-in" projects. 如果您不想在同一解决方案中编译那些“加载项”项目,而是在运行时加载它们,则可以直接引用那些“加载项”项目的
.dll
文件。 Or you can package your Library assemblies with NuGet. 或者,您可以使用NuGet打包库程序集。 You can then use NuGet in Visual Studio to take care of all these references.
然后,您可以在Visual Studio中使用NuGet来处理所有这些引用。 In those case, the "add-in" projects aren't compile, but are loaded at run-time.
在这种情况下,“加载项”项目不会编译,而是在运行时加载。
If you just want not copy those libraries of "add-in" projects into the output directory for reference project, you can set the property " Copy Local
" of those references to false. 如果只不想将那些“附加”项目库复制到参考项目的输出目录中,则可以将这些引用的属性“
Copy Local
”设置为false。
Update for comment: 更新评论:
I'd like to develop the "add-in" projects in the same solution.
我想在同一解决方案中开发“附加”项目。 Do you advise against this workflow?
您反对此工作流程吗?
The simple answer is yes. 简单的答案是。 If you develop the "add-in" projects in the same solution, when you make any modification in the referenced project, the reference project will be recompile, which will destroy your previous deploy.
如果在同一解决方案中开发“外接程序”项目,则在引用的项目中进行任何修改时,将重新编译引用的项目,这将破坏以前的部署。 So I do not recommend develop the "add-in" projects in the same solution, you can move it to a new solution.
因此,我建议您不要在同一解决方案中开发“外接程序”项目,而可以将其移至新解决方案。 If you still want to develop that projects in the same solution, you can refer to my previous advice "package your Library assemblies with NuGet. You can then use NuGet in Visual Studio to take care of all these references.".
如果仍要在同一解决方案中开发这些项目,则可以参考我以前的建议“将Nuts与Library组件打包在一起。然后可以在Visual Studio中使用NuGet来处理所有这些引用。” In this case, the previous deploy would not be destroyed When you develop add-in project.
在这种情况下,开发外接程序项目时,先前的部署不会被破坏。
Hope this helps. 希望这可以帮助。
Just use P2P references everywhere to make it work. 只需在各处使用P2P引用即可使其工作。 That is, prefer a working build system over the cosmetics of not directly having referenced the "add-in" projects.
也就是说,相对于未直接引用“附加”项目的外观,更喜欢可工作的构建系统。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.