Skip to content
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

Consider replacing CoreCompileCache with Roslyn DeterministicKey #7043

Open
rainersigwald opened this issue Nov 17, 2021 · 2 comments
Open
Labels
Area: Common Targets needs-design Requires discussion with the dev team before attempting a fix. triaged
Milestone

Comments

@rainersigwald
Copy link
Member

Roslyn is considering exposing an API to compute a key that describes the inputs to a compilation (dotnet/roslyn#57162).

That could be used to replace the CoreCompileCache concept in Common.targets:

<!--
============================================================
_GenerateCompileDependencyCache
Generate a file used to track compiler dependencies between incremental build
executions. This handles cases where items are added or removed from a glob (e.g.
<Compile Include="**\*.cs" />) and can't otherwise be detected with timestamp
comparisons. The file contains a hash of compiler inputs that are known to
contribute to incremental build inconsistencies.
============================================================
-->
<Target Name="_GenerateCompileDependencyCache" Condition="'$(DesignTimeBuild)' != 'true' and '$(BuildingProject)' == 'true'" DependsOnTargets="ResolveAssemblyReferences">
<ItemGroup>
<CustomAdditionalCompileInputs Include="$(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache" />
<CoreCompileCache Include="@(Compile)" />
<CoreCompileCache Include="@(ReferencePath)" />
<CoreCompileCache Include="$(DefineConstants)" />
</ItemGroup>
<Hash
ItemsToHash="@(CoreCompileCache)"
IgnoreCase="$([MSBuild]::ValueOrDefault(`$(CoreCompileCacheIgnoreCase)`, `true`))">
<Output TaskParameter="HashResult" PropertyName="CoreCompileDependencyHash" />
</Hash>
<WriteLinesToFile Lines="$(CoreCompileDependencyHash)" File="$(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache" Overwrite="True" WriteOnlyWhenDifferent="True" />
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)$(MSBuildProjectFile).CoreCompileInputs.cache" />
</ItemGroup>
</Target>

That was introduced to avoid problems with the Compile list changing between runs (#1328).

However, if Roslyn exposed a task with similar API to the Csc/Vbc tasks that returned (something like) the DeterministicKey instead of doing compilation, we could use that output instead (instead of having to follow the CoreCompile inputs as in #5334).

This came up when @RikkiGibson and I were talking about some stuff.

@rainersigwald rainersigwald added needs-design Requires discussion with the dev team before attempting a fix. Area: Common Targets labels Nov 17, 2021
@rainersigwald rainersigwald added this to the Backlog milestone Nov 17, 2021
@RikkiGibson
Copy link

cc @jaredpar

@jaredpar
Copy link
Member

This seems like a good use case for the API. Calculating this key though does require us to effectively read in all of the files that will be used in a compilation event: source files, references, etc ... The key is content based hence it needs the values.

Given we'd likely do this work in the server that probably won't add a ton of cost. Many of the values are already cached there but do want to make sure we're clear that is part of the operation here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Common Targets needs-design Requires discussion with the dev team before attempting a fix. triaged
Projects
None yet
Development

No branches or pull requests

4 participants