Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to make a transitive task?#11382

Unanswered
timcassell asked this question inQ&A
Feb 4, 2025· 1 comments· 4 replies
Discussion options

I created a task to run an assembly weave withMono.Cecil in an after build target. I want this task to run on all projects that reference my project via<ProjectReference>.

From working with CoPilot, it explained thatProjectReferences cannot have transitive tasks, onlyPackageReferences can via .targets file. So I thought, ok, I can just use aBeforeTargets="Restore" task exec command powershell script to clear the nuget cache and build the package, and add aPackageReference to the newly built package with a local<RestoreSources>, and that will be transitive. This seems to work fine when I build my project (usingdotnet build), however, when I build another project that has aProjectReference to my project, the target doesn't run, so my script doesn't execute, and the build fails if the package didn't exist already (or doesn't have up-to-date code if it did exist).

When I ask CoPilot how to solve it, it just goes around in circles. Am I missing something, or is it just not possible? It feels so close...

You must be logged in to vote

Replies: 1 comment 4 replies

Comment options

ProjectReference doesn't really get parity withPackageReference. It misses various features like native assets.

Publishing an intermediate NuGet package (even to local disk) could be a viable workaround.

You must be logged in to vote
4 replies
@timcassell
Comment options

Publishing an intermediate NuGet package (even to local disk) could be a viable workaround.

Yeah, that's what I ended up doing.

It's a sub-par experience if you want to share source code and have referencing projects auto-update when the source code is changed like how project references work. Are there any plans to improve this type of workflow?

@huoyaoyuan
Comment options

Maybe it belongs to NuGet? LikeNuGet/Home#6826

@timcassell
Comment options

I think more like MSBuild should have the ability to compile and run a Task from source, rather than having to target a pre-compiled dll, then having that Task source be a transitive dependency. (I can already do half of that - compile and run it from a shell script - but it can't be transitive.)

@timcassell
Comment options

Or I guessProjectReference just needs to make more things transitive likePackageReference (I just found out that analyzers are also not transitive viaProjectReference).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@timcassell@huoyaoyuan

[8]ページ先頭

©2009-2025 Movatter.jp