-
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
Post build event is run an extra time with empty values when multi-targeting #11277
Comments
This is expected behaviour, and we need to improve the documentation around it. But how it works, when you have This extra post build that you are seeing is from the outer build, that is also used in some cases, and removal would probably break a lot of builds. |
@maridematte we should probably add some documentation about the general pattern to https://learn.microsoft.com/en-us/dotnet/standard/frameworks - I can log a docs bug for that. I don't see that it's been specified anywhere. |
@rwb196884 for reference, here is the main bit of code relating to multi-targeted builds: msbuild/src/Tasks/Microsoft.Common.CrossTargeting.targets Lines 109 to 162 in 27b56ae
When building, as @maridematte said you should expect more than one build of the project to occur:
As a result, it's very important to make sure that targets run in the correct context - this is why NuGet packages that ship MSBuild targets have both the If you'd like to ensure that your target only runs when a single TFM has been specified, you probably need to add an additional check to your Condition like |
Issue Description
I've added a post build event to my csproj to sign DLLs (getting this to run in the Azure DevOps pipeline was hell -- took a day.)
The
Condition
is required beause the target is run for ever<Frameworks
and again for the empty string.The problem happens when you use
<TargetFrameworks
instead of<TargetFramework
. Example attached.Steps to Reproduce
ConsoleAppPostBuildEvent.zip
Expected Behavior
Don't run the post build event an additional time.
Actual Behavior
Runs post build event once for every frameowrk and agan with empty parameter values.
Analysis
No response
Versions & Configurations
No response
The text was updated successfully, but these errors were encountered: