Skip to content

[vs17.14] Binlog not produced for C++ project on Visual Studio Load Fix #11774

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

Merged
merged 4 commits into from
Apr 30, 2025

Conversation

surayya-MS
Copy link
Member

@surayya-MS surayya-MS commented Apr 28, 2025

Fixes #11678

Work item (Internal use):

Summary

Regression in Visual Studio 17.13 (worked in 17.12).
Binlog is not created for C++ project on Visual Studio load.

Customer Impact

Harder to diagnose build failures/perf issues for vcxproj in VS.

Regression?

Yes, from 17.12 to 17.13.

Testing

Manual testing:

  1. Get any C++ projec. I got it from the feedback ticket
  2. In the terminal set MSBUILDDEBUGENGINE and MSBUILDDEBUGPATH
  3. in the same terminal open the C++ project with devenv
  4. Check the MSBUILDDEBUGPATH for the binlogs

For using the correct msbuild

  1. Use build.cmd script
  2. Use ~\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current instead of {Visual Studio path }\MSBuild\Current

Risk

Low--spot fixes of refactorings.

Details

The bug is on this line:

return (loggers ?? [logger]);

The PR that changed this line:
https://github.com/dotnet/msbuild/pull/10758/files#diff-2b0716a511d8f4ee690ebd5c3a59dec1e3f9a5eab4ab2a80a1018820a658accbL671

The code before and after

- return (loggers ?? Enumerable.Empty<ILogger>()).Concat(new[] { logger });
+ return (loggers ?? [logger]);

Before logger (BinaryLogger here) was always included.

Changes Made

Made sure to include the BinaryLogger.

Notes

There is also a same mistake with misplaced brackets here:
https://github.com/dotnet/msbuild/pull/10758/files#diff-9ee98aebd9b1aea9900e0b2859bdcbe6b6bdda285f4b5771d9bdeb8b2f480b8dL1708

- var inputs = (this.References ?? Enumerable.Empty<ITaskItem>()).Concat(this.AdditionalInputs ?? Enumerable.Empty<ITaskItem>());
+ ITaskItem[] inputs = this.References ?? [..(this.AdditionalInputs ?? [])];

Also fixed this mistake in this PR.

@Copilot Copilot AI review requested due to automatic review settings April 28, 2025 15:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a regression where the BinaryLogger was not being included during Visual Studio C++ project load by correcting array and collection concatenation. Key changes include:

  • In GenerateResource.cs, replacing the erroneous array literal syntax with proper concatenation of reference and additional inputs.
  • In BuildManager.cs, updating the logger concatenation to correctly include the BinaryLogger using empty array fallback.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Tasks/GenerateResource.cs Fixed concatenation of inputs by replacing the faulty bracket syntax with a Concat call.
src/Build/BackEnd/BuildManager/BuildManager.cs Updated logger inclusion to use empty array fallback and Concat, ensuring the BinaryLogger is always included.
Comments suppressed due to low confidence (2)

src/Tasks/GenerateResource.cs:1708

  • The change correctly replaces the invalid array literal syntax with Concat to merge inputs. Ensure that downstream code expecting an array can work with the resulting IEnumerable or convert it to an array if needed.
            var inputs = (this.References ?? []).Concat(this.AdditionalInputs ?? []);

src/Build/BackEnd/BuildManager/BuildManager.cs:680

  • The update uses Concat with an empty array fallback to include the BinaryLogger correctly. Verify that the new array literal syntax ([logger]) aligns with the project’s C# version and style guidelines.
                return (loggers ?? []).Concat([logger]);

@surayya-MS surayya-MS requested a review from a team as a code owner April 28, 2025 15:16
@surayya-MS surayya-MS enabled auto-merge (squash) April 28, 2025 15:39
Copy link
Member

@AR-May AR-May left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants