Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to express project dependencies in Traversal SDK? #504

Open
hickford opened this issue Nov 13, 2023 · 1 comment
Open

How to express project dependencies in Traversal SDK? #504

hickford opened this issue Nov 13, 2023 · 1 comment

Comments

@hickford
Copy link

In a Visual Studio solution, I can explicitly express dependencies between projects. This is useful when projects implicitly depend on the output of other projects, so that Visual Studio can calculate a compatible build order.

How can I describe project dependencies in a Microsoft.Build.Traversal SDK proj?

@jeffkl
Copy link
Contributor

jeffkl commented Nov 13, 2023

Unfortunately, build ordering in a solution file is not a very good best practice. Since the ordering is only respected when building the solution file, this means that when you build projects instead, the build ordering is not guaranteed. The better solution is to declare dependencies directly in each project. This will have your build order respected in Visual Studio and the command-line, whether you're building a solution or a project.

Are you able to add <ProjectReference /> items in the projects to explicitly declare a dependency? You can set metadata like ReferenceOutputAssembly to not actually pass the reference to the compiler and just have it declared as a dependency:

<ItemGroup>
  <!-- Declare a build dependency on a project but don't actually depend on the assembly at compile time -->
  <ProjectReference Include="..\SomeDependency\SomeDependency.csproj" ReferenceOutputAssembly="false" />
</ItemGroup>

If you run into target framework incompatibility, you can also set SkipGetTargetFrameworkProperties=false to bypass the check and just have the dependency declared for build ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants