-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Feature request: Simple way to express an order-only dependency. #4795
Comments
I can confirm that this behaviour is occuring, I have a synthetic project that only needs to be built but any
is copied to projects with reference to synthetic project
|
Thanks to a random stackoverflow post, we now know that |
You made my day. Here the SO post for reference: https://stackoverflow.com/questions/26242937/what-does-the-private-setting-do-on-a-projectreference-in-a-msbuild-project-file. When you don't need any CopyTo[..]Directory functionality in synthetic project, an another workaround might be:
But I am not sure which further implications this workaround may have. |
Hi, I want just to state, that |
cc @dsplaisted for the nuget/CLI/SDK sync |
Investigated with @rainersigwald: tl;dr;: Strictly speaking Workaround: Specifying Background: The netcore application produces the Changing the behavior so that even the Possible fix: So the possible way of fixing this is to define another metadata (e.g. something like Conclusion: |
@JanKrivanek : In .NET 6, In case anybody is wondering, the use case is there's a compiler in the build tree that outputs |
@jhudsoncedaron It works - see #4371 (comment) for more context. |
@JanKrivanek : Ah. I just didn't have the rest of the items to set from the other thread. |
The current sequence to reference a project for dependency purposes but not actually reference a project in the output is:
Each of these settings does a different piece of what is necessary to get a pure build order dependency.
I have to admit I'm starting to get disgusted because this list grows over time and isn't discoverable. |
We are switching to solution generation, and none of the solution generators we have found have support for sln-level ProjectDependencies. We tried creating a shortcut OrderingOnly="true" attribute and a custom BeforeTargets="BeforeBuild" Target to update ProjectReferences with all the boilerplate described by @jhudsoncedaron but we are abandoning the effort. We encountered problems that we believe are related to special treatment of ProjectReference items within msbuild and VS. One of our dependencies happens to cause a namespace ambiguity that fails the build when it is treated as an actual reference, so we know that Interestingly, some kind of caching within VS allows our fix to work during a second VS build, but not on rebuild nor when using msbuild.exe. We believe the issue is related to special treatment of ProjectReference items because we note in the .binlog that a single ProjectReference item creates many mirrored item types at project load time: AnnotatedProjects, ProjectReferenceWithConfiguration, _MSBuildProjectReference, _MSBuildProjectReferenceExistent, _ProjectReferenceTargetFrameworkPossibilities, _ProjectReferenceTargetFrameworkPossibilitiesOriginalItemSpec. Presumably one of these is actually used internally to handle the ReferenceOutputAssembly metadata, and our transformation occurs too late for that item to get updated appropriately. |
@jhudsoncedaron I find that SelfContained and SkipGetTargetFrameworkProperties cause problems . Either of them will push the referenced project into a separate batch and a separate node in the dependency graph, causing it to build twice. You can see this happening by searching the binlog for In our ecosystem this double build tends to cause transient build failures during Rebuild, if the Clean of one instance runs concurrently with the Build of the other. We have an |
@chipplyman : There's a simple way to avoid this issue. Create a .sln file with only the final build targets in it, and build it with |
@jhudsoncedaron for us, it's simpler to just omit those problematic properties. They don't seem to have any impact on the build when omitted. That may be only because we're still singly targeting .net 4.8 but for now it works. |
@chipplyman : Ah. In my case it will not build. You are certainly getting away with it by targeting .net 4.8. |
@jhudsoncedaron I just hope this discussion demonstrates to the msbuild team that there exists an urgent need for a project-level ordering-only dependency declaration feature. |
In some ways the Aspire AppHost is driven by this same concept. The AppHost uses ProjectReferences to service projects mostly as a way to 'track' the projects, and the only build-related thing it actually uses is implicit - when cc @DamianEdwards @davidfowl for awareness. |
Hmm, random thought, what if we had something like a |
@DamianEdwards : I mean we could; but they still have to fix the .sln double build bug. (Bug doesn't exist when you build out of a project file; but there's no way to build n project files in a single build step where n > 1 except for a .sln file so most people just build their .sln file that has everything in it.) |
@chipplyman : SelfContained and SkipGetTargetFrameworkProperties are required to cross compile. |
Seems that the workaround here does not work anymore. My referenced project uses a different |
I'm in the same boat as the OP. My solution contains an OutputType=EXE project that is referenced by another project to trigger custom (non-C#) source generation but I do not want the source generator EXE to appear in the output of the referencing project. Only the magic incantation in #4795 (comment) works, but that's just gross. |
Previously (net core 2.1), this worked:
Now, it doesn't, and even all this doesn't work:
What's going on is I have a build tool in the solution, and
dotnet publish
is trying (incorrectly) to ship it. Almost minimized sample attached. If it were any smaller it wouldn't make any sense.depbuildtool.zip
The text was updated successfully, but these errors were encountered: