dotnet / dotnet/msbuild

ProjectReference: How to make one project to consume/import assets (content, props, targets) from another project?

Open
#5,797 11 comments 9 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

I need to make project with some msbuild properties, tasks and targets which will be consumed by another project.

When my consumer-project references nuget package via `PackageReference` then consumer-projects can consume any assets: assemblies, content, props, targets and probably a lot more from package.

> This is accomplished with [MSBuildProjectExtensionsPath](https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019#msbuildprojectextensionspath) (project implicitly imports `obj/MyProject.*.props` and `obj/MyProject.*.targets`).
> And NuGet creates `MyProject.csproj.nuget.g.props` and `MyProject.csproj.nuget.g.targets` which just adding content items and importing props and targets.

But when my consumer-project references another project then consumer-project can consume only assembly.
Is it possible to consume other assets?

I've found next ProjectReference's metadata, but there is a little information in documentation. So, I don't know if this can help me.
```
All
None
None
True
Content
true
Always
True
```
Of course I can just manually write imports to my props and targets. But there must be a better way. Or not?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.