在不使用引用的情况下设置构建依赖项?

时间:2021-04-03 02:50:04

All: I am working on a solution where one of the projects is actually plug-in to the main exe that the solution builds. Since this one project is a plug in, it's wrong to reference the plug-in from the main exe (that assembly isn't guaranteed to be present in a deployment, it's optional).

全部:我正在开发一个解决方案,其中一个项目实际上插入了解决方案构建的主exe。由于这个项目是一个插件,从主exe引用插件是错误的(该程序集不保证在部署中存在,它是可选的)。

So here's my problem: If I modify code in my plug-in project, and then hit F-5 to run, Visual Studio will not alwyas build my plug-in (since based upon the reference tree, the main exe does not appear to depend upon it).

所以这是我的问题:如果我在我的插件项目中修改代码,然后点击F-5运行,Visual Studio将不会构建我的插件(因为基于参考树,主exe不会出现取决于它)。

Is there a solution or project-level setting that I could change to cause this plug-in project to be included when I run (without adding a reference)?

是否有解决方案或项目级别的设置,我可以更改以便在运行时包含此插件项目(不添加引用)?

I know about the global setting in tools | options | Build and Run, but I'd rather not have to change VS's behavior globally just to get this solution to build right (also, if the setting goes with the solution or project, then when other developers check it out, they should simply inherit the setting)

我知道工具的全局设置选项|构建和运行,但我宁愿不必全局改变VS的行为只是为了使这个解决方案正确构建(同样,如果设置与解决方案或项目一致,那么当其他开发人员检查它时,他们应该只是继承设置)

BTW: these are c# projects in a VS 2005 solution.

顺便说一句:这些是VS 2005解决方案中的c#项目。

2 个解决方案

#1


Right click the root node in Solution Explorer -> Properties -> Project Dependencies. (VS 2008 users: this feature gets its own dialog box that's directly accessible from the context menu.)

右键单击解决方案资源管理器 - >属性 - >项目依赖项中的根节点。 (VS 2008用户:此功能有自己的对话框,可以从上下文菜单中直接访问。)

The dependency graph is represented as an adjacency list of checkboxes. Each project you select will have its direct references checked & disabled [assuming you use project refs, not assembly refs]. Other checkboxes might be disabled if they would create a circular dependency.

依赖关系图表示为复选框的邻接列表。您选择的每个项目都将检查和禁用其直接引用[假设您使用项目引用,而不是程序集引用]。如果它们会创建循环依赖项,则可能会禁用其他复选框。

For any checkbox not disabled, checking/unchecking will write a ProjectSection(ProjectDepedencies) section into your solution file. So your settings will propagate to other developers via source control.

对于未禁用的任何复选框,检查/取消选中会将ProjectSection(ProjectDepedencies)部分写入解决方案文件。因此,您的设置将通过源代码控制传播给其他开发人员。

Fair warning though: if you use MSBuild (including any version of Team Build), it does not always handle *.sln file customizations the same way that builds inside Visual Studio do. *.sln is not a native MSBuild file type, unlike *.??proj files. I myself have run into the problem described here; I've also seen the opposite behavior on occasion.

但是公平警告:如果您使用MSBuild(包括任何版本的Team Build),它并不总是像在Visual Studio中构建一样处理* .sln文件自定义。 * .sln不是本机MSBuild文件类型,与*。?? proj文件不同。我自己也遇到了这里描述的问题;我偶尔也会看到相反的行为。

#2


Can I suggest creating a dummy (empty) project, to represent the combination of the main exe and the plugin, and configuring that project to be dependent on both, but run the EXE on launch?

我是否可以建议创建一个虚拟(空)项目,表示主exe和插件的组合,并将该项目配置为依赖于两者,但是在启动时运行EXE?

#1


Right click the root node in Solution Explorer -> Properties -> Project Dependencies. (VS 2008 users: this feature gets its own dialog box that's directly accessible from the context menu.)

右键单击解决方案资源管理器 - >属性 - >项目依赖项中的根节点。 (VS 2008用户:此功能有自己的对话框,可以从上下文菜单中直接访问。)

The dependency graph is represented as an adjacency list of checkboxes. Each project you select will have its direct references checked & disabled [assuming you use project refs, not assembly refs]. Other checkboxes might be disabled if they would create a circular dependency.

依赖关系图表示为复选框的邻接列表。您选择的每个项目都将检查和禁用其直接引用[假设您使用项目引用,而不是程序集引用]。如果它们会创建循环依赖项,则可能会禁用其他复选框。

For any checkbox not disabled, checking/unchecking will write a ProjectSection(ProjectDepedencies) section into your solution file. So your settings will propagate to other developers via source control.

对于未禁用的任何复选框,检查/取消选中会将ProjectSection(ProjectDepedencies)部分写入解决方案文件。因此,您的设置将通过源代码控制传播给其他开发人员。

Fair warning though: if you use MSBuild (including any version of Team Build), it does not always handle *.sln file customizations the same way that builds inside Visual Studio do. *.sln is not a native MSBuild file type, unlike *.??proj files. I myself have run into the problem described here; I've also seen the opposite behavior on occasion.

但是公平警告:如果您使用MSBuild(包括任何版本的Team Build),它并不总是像在Visual Studio中构建一样处理* .sln文件自定义。 * .sln不是本机MSBuild文件类型,与*。?? proj文件不同。我自己也遇到了这里描述的问题;我偶尔也会看到相反的行为。

#2


Can I suggest creating a dummy (empty) project, to represent the combination of the main exe and the plugin, and configuring that project to be dependent on both, but run the EXE on launch?

我是否可以建议创建一个虚拟(空)项目,表示主exe和插件的组合,并将该项目配置为依赖于两者,但是在启动时运行EXE?