简体   繁体   English

在不使用项目参考的情况下设置构建顺序

[英]Set build order without using project reference

In our solution we have more than 150 projects, now most of projects are using some .js file, which is generated by another project. 在我们的解决方案中,我们有150多个项目,现在大多数项目使用的是.js文件,该文件是由另一个项目生成的。 So I need build this project before others. 因此,我需要先构建这个项目。 I know I can set the other projects are reference this project, but the problem is that we have nearly 100 projects that needs those .js file, add this project as reference project to 100 projects is not the best option. 我知道我可以将其他项目设置为引用此项目,但是问题是我们有将近100个需要这些.js文件的项目,将这个项目作为参考项目添加到100个项目中并不是最好的选择。

So how can I set the build order without adding project reference? 那么,如何在不添加项目参考的情况下设置构建顺序呢?

Thanks any advice. 谢谢你的建议。

In Visual Studio, for each project that depends on your dependant project X : 在Visual Studio中,对于依赖于依赖项目X的每个项目:

  1. Right-click project 右键单击项目
  2. Choose Build Dependencies... 选择构建依赖项...
  3. Choose Project Dependencies 选择项目依存关系
  4. Tick the project this project depends on 勾选该项目所依赖的项目
  5. Click OK 点击确定
  6. Repeat steps 1-5 for all other projects 对所有其他项目重复步骤1-5

Sadly, selecting multiple projects (at least in VS2017) won't let you apply the settings to more than one project at a time 可悲的是,选择多个项目(至少在VS2017中)将不允许您一次将设置应用于多个项目

how can I set build order without adding project reference? 如何在不添加项目参考的情况下设置构建顺序?

You do not want to set project reference or project dependencies to each of those 100 projects, but there is no such option that you can set multiple references at once. 您不想为这100个项目中的每个项目设置项目引用或项目依赖项,但是没有可以一次设置多个引用的选项。

To resolve this problem, I would like provide you two workarounds. 要解决此问题,我想为您提供两种解决方法。

  • Build that referenced project first, then build the solution. 首先构建引用的项目,然后构建解决方案。

    In this way, you should pay a attention to manually build the referenced project first. 这样,您应该注意首先手动构建引用的项目。 It seems you are not independent developer, this way should not the best option. 看来您不是独立开发人员,所以这不是最佳选择。

  • Using batch file to set the build order. 使用批处理文件设置构建顺序。

You can use batch file to set build order, build the referenced project first, then build the solution: 您可以使用批处理文件设置构建顺序,首先构建引用的项目,然后构建解决方案:

    @echo OFF 
    call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat"
    echo "Starting Build for all Projects with proposed changes"
    MSBuild.exe "C:\Users\Admin\Source\repos\TestMSBuildOrder\GenerateJSFileProject\GenerateJSFileProject.csproj"
    MSBuild.exe "C:\Users\Admin\Source\repos\TestMSBuildOrder\TestMSBuildOrder.sln"
    pause
    echo "All builds completed." 

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用MSBuild构建.csproj而不使用项目引用 - Build .csproj with MSBuild without project reference 处理大型项目中的依赖项...是否可以可靠地更改构建顺序,而无需在C#/ VS2008中使用项目依赖项? - Dealing with dependencies in a large project… Is it possible to reliably alter build order without using project dependencies in C#/VS2008? 添加项目引用后的 System.MissingMethodException(不使用引用) - System.MissingMethodException after adding a project reference (without using the reference) 对象未设置为在构建中引用 - Object not set to reference in build 从哪里可以为项目设置“构建”或“不构建”合同参考? - From where we can set “Build”or “Do Not Build” Contract reference for a project? 没有C的参考项目B - Reference project B without C 在Ubuntu 16.04上使用Rider的C#项目中的“未找到项目”和“未将对象引用设置为对象的实例” - “Project not found” and “Object reference not set to an instance of an object” in a C# project using Rider on Ubuntu 16.04 将Exe引用添加到来自构建事件的项目 - Add a Exe Reference To a Project From build event 在 Visual Studio 中引用一个项目并为特定平台构建它 - Reference a project in Visual Studio and build it for a specific platform 运行 do.net build 时项目引用未解析 - Project reference not resolved when running dotnet build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM