Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking a bit more about this. Why is
ApiCompat
hooked into$(TargetsTriggeredByCompilation)
? That doesn't seem like the ideal place for it to be hooked into the build. I would have expected it to be anAfterTargets="Build"
orAfterTargets="CoreBuild"
, something along those lines.If we are going to keep it hooked into
$(TargetsTriggeredByCompilation)
and if we didn't want to depend on the$(DesignTimeBuild)
property, it looks like a different property we could check is$(SkipCompilerExecution)
. This is the property that tellsCoreCompile
to not actually compile the C# code during these design-time builds. It is paired with$(ProvideCommandLineArgs)
, which tells theCsc
task to just output the fullcsc.exe
command line args, which VS uses. It seems reasonable to not runApiCompat
when$(SkipCompilerExecution) == true
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#determining-whether-a-target-is-running-in-a-design-time-build, it looks like depending on
$(DesignTimeBuild)
is acceptable.QUESTION: Should this change also go into https://github.com/dotnet/arcade/blob/master/src/Microsoft.DotNet.ApiCompat/build/Microsoft.DotNet.ApiCompat.targets#L21? Does it ever make sense to run ApiCompat during a DesignTimeBuild? Reading that project-system doc:
I don't think ApiCompat changes references, source files or compilation options, right? So it would seem best to default it to
off
during a DesignTimeBuild.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @eerhardt on that. Let's move the fix over to arcade and change the defaults in ApiCompat.targets to not run on design time builds. I would not merge this in to not add unnecessary complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my Build Logging window when ApiCompat is running during DesignTimeBuild:
And when I shut it off:
Notice that the time went from 2 seconds down to under 0.1 seconds for the
netstandard2.0
design time build. If you had a few projects in a single solution, doing ApiCompat would be taking a lot of time.