-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Find a way to embed project.assets.json in .binlog #3529
Comments
What scenarios aren't well-served by just looking at the results of the asset-file-reading task? Maybe some kind of advisory API from within a task: "it'd be interesting to capture this file"? IBuildEngine6.LogFileContents(string path) (Someday we're going to get into double digits on that interface and it will be something to behold.) We wouldn't want folks to abuse this for everything (if you need to debug contents of source files, build locally), but for build-graph-altering things like the assets file it could be handy. |
Here's an example where I needed the contents of project.assets.json: |
A naïve way to do that that works well is just add this to BinaryLogger.CollectImports():
|
Suggestions welcome on how to name the item Then you could just do
to embed the file in binlog. Embedding all project.assets.json roughly doubles the size of the files archive, from 450K to 900K. Feels like it's worth it though because project.assets.json contain valuable information not available elsewhere, e.g. why was a certain file chosen to be CopyLocal. |
It's unclear when to embed the file. ProjectStarted or ProjectEvaluationFinished may be too early as the file may not exist yet. But I guess in the majority of cases when a project is being built the Restore already happened. TargetFinished for Restore target could be another location. |
I feel like I should first fix #5316 so we can better enumerate items after evaluation. |
It would be very useful to embed more than just the project files into the binlog. For example, project.assets.json is a common request: #3529. global.json or nuget.config would be other examples. Some users may want to embed all *.cs files as well. Add a special EmbedInBinlog item type recognized by BuildEventArgsWriter. If after evaluation the items contain EmbedInBinlog, all such items will be logged if the evaluated include points to a full file path that exists on disk. A given file can be mentioned more than once, but will only be embedded once. If a file doesn't exist or is empty, it will not be embedded. If the item is added from a target (after evaluation is done), it will not be embedded. Checking for EmbedInBinlog is done in BuildEventArgsWriter to reuse the complicated and performance-optimized logic of iterating over all items.
We're thinking of adding a way to embed arbitrary files in the binlog. See dotnet/msbuild#6339 project.assets.json is commonly requested to be embedded. This would fix dotnet/msbuild#3529 Binlog size does increase from 3.5 MB -> 5 MB, so we'll need to think perhaps about making it off by default.
It would be helpful to include the
project.assets.json
file from the obj directory in the .binlog file archive.Not sure what's the best way to do it as it's not technically an MSBuild file.
The text was updated successfully, but these errors were encountered: