-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Milestone
Description
Steps to reproduce
- Create a solution
- Add a project
- Edit the .csproj to add a target like
<Target Name="MyTarget" AfterTargets="Restore">
<!-- Whatever you want it to do -->
</Target>
- From command line, run msbuild on your project, with restore and generate a binlog
msbuild YourProjectName.csproj /r /bl - Look at the msbuild.binlog file that's generated. MyTarget will be immediately after the Restore target.
- From command line, run msbuild on your solution with restore and generate a binlog
msbuild YourSolutionName.sln /r /bl - Look at the msbuild.binlog file that's generated. MyTarget will not be run at all.
Expected behavior
MyTarget target is run after Restore target.
Actual behavior
MyTarget target is never run
Environment data
msbuild /version output:
Microsoft (R) Build Engine version 16.5.0-preview-19562-03+d72e25031 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
16.5.0.56203
OS info:win
Other info
- The same thing is true for BeforeTargets as AfterTargets as far as I can tell.
- It looks like the problem is because there is no Restore target on the individual project when building from the solution. There is just one "meta" Restore target no matter how many projects are in the solution
Question
So the question then becomes, how do we do this properly? I want to do some extra restore stuff whenever a restore is done, but not worry about it at build time.
petrkoutnycz, AraHaan, Meligy, nvirth, NoTuxNoBux and 4 more