-
Notifications
You must be signed in to change notification settings - Fork 17
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
moving the <None> items into targets to force correct ordering #97
base: master
Are you sure you want to change the base?
Conversation
85edbd1
to
c1401c0
Compare
@SimaTian Thanks for looking into this. If I understand your explanation correctly, the issue is that by default, plain I'm currently working on a linux port of this library, and I tried to apply your idea to this branch as well (the <Target Name="RunAfterBuildIsDone" AfterTargets="ResolveProjectReferences">
<ItemGroup>
<!-- Include all files in the Resources folder but copy them directly to the output directory -->
<None Update="Resources/*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>%(RecursiveDir)/../%(Filename)%(Extension)</Link>
<Pack>true</Pack>
<PackageCopyToOutput>true</PackageCopyToOutput>
</None>
<!-- The graphviz subfolder is only present and relevant on linux -->
<None Update="Resources/graphviz/*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>%(RecursiveDir)/../../graphviz/%(Filename)%(Extension)</Link>
<Pack>true</Pack>
<PackageCopyToOutput>true</PackageCopyToOutput>
</None>
</ItemGroup>
</Target> However, after putting these in a target per your suggestion, these commands start misbehaving. Among other things, they now emit the following warnings:
I'm extremely confused as to how putting the items in a target results in these warnings. I looks like the |
Hello @chtenb, I'm sorry I completely missed your response, I wasn't monitoring this issue, I just checked since I was cleaning my workspace and chanced upon the folder I used for the reproduction. Did you have any luck since you encountered the issue? I'll add this on my todo list and check later this week. I'm sorry for the delay. |
@SimaTian Hi again. I'm still having the same issue on the RE issue monitoring: activity in threads I've participated in always show up in my github notifications by default. I think you can also setup email notifications if you don't look at github regularly. |
My github notifications are completely overrun with dotnet stuff so I'm agressively filtering for those from msbuild repository only. (I'm not yet used to the world where I occasionally contribute to repositories that aren't mine) |
@chtenb One detail I'm unsure about after some testing: If you're trying to copy files to a directory, could you try going this route instead? Doing something like:
Appeared to be working, though it's most likely not doing exactly what you're trying to do. |
As you have seen on the
Now this seems to work fine, except when I move this into a Target in the manner that your suggested as a solution for forcing the correct build step order. I'm not hung up on this exact solution, but how would I replicate this behavior within a Target per your suggestion? So copying the contents of Resources/ to the output directory. |
There are several things at play here, and I would have to dig deeper than I can right now. I'll leave some suggestions here hoping that it will work. If yes, great. If no, I will check later when I have more time.
However from what I could find and dig into, the CopyToOutputDirectory is handled by some MSBuild target, not in the MSBuild engine itself - and it is just using the <Copy> task under the hood. After that there is the teeeny issue with packing where I'm unsure how does it interact with copy task. |
Thanks for your response. I've tried to make it work with Copy in the past, but it always failed to register transitively. So referencing projects wouldn't get the resources in their output. I don't remember if it worked with the nuget packaging process, maybe there were issues with that as well like you say. The |
Follow up for Order of projects in solution file affects build results
Original reproduction here
The blog here mentions how to include generated file. This case was a bit specific and required slightly different setup because the wasn't enough to enforce correct ordering.
Basically the issue is that if the item isn't within a target, it is resolved during Evaluation phase - e.g. as soon as the project file is loaded into the MSBuild, but ProjectReference that is setting up the project dependency ordering is a Target so this happens:
By moving the item into a custom target and forcing order by setting AfterTargets, the files are moved correctly. Tests pass.
Interestingly enough, since the files are not processed further, another(albeit rather weird) way to have a working build without using the target is to run the build twice. This both made my reproduction attempts somewhat unwieldy and hinted me to a correct solution.
Kudos for Jan Krivanek for letting me know about the MSBuildism blog and to Jenny Bai for her work on reproducing the issue and collecting the logs.