Skip to content

QoL | Enable incremental build in Visual Studio#3993

Open
edwardneal wants to merge 1 commit intodotnet:mainfrom
edwardneal:build/enable-incremental
Open

QoL | Enable incremental build in Visual Studio#3993
edwardneal wants to merge 1 commit intodotnet:mainfrom
edwardneal:build/enable-incremental

Conversation

@edwardneal
Copy link
Contributor

Description

At present, Visual Studio builds are fairly slow - even when changing tests, the SqlClient projects are fully rebuilt. This PR makes the GenerateThisAssemblyCs target support incremental build, cutting the rebuild times dramatically (particularly noticeable when changing and running tests.)

Variations of GenerateThisAssemblyCs appear in a few places in dotnet/runtime. Microsoft.XmlSerializer.Generator has a fairly similar copy. System.Diagnostics.DiagnosticSource chooses a slightly different wrapper: a simple _GenerateThisAssemblyInfo target in the project file. I've hemmed more closely to the first of these places.

The core changes are twofold:

  • Specify Inputs and Outputs on the target, to indicate that it supports incremental build.
  • Add ThisAssembly.cs to the FileWrites item, ensuring that a clean will remove it when needed.

I also noticed that the license header was missing from the generated file, so added it for completeness' sake. There were also two path separators in the output location, so I removed the second of these.

Issues

None.

Testing

Tested rebuilds with Visual Studio. Confirmed that this file is removed by the Clean target.

@edwardneal edwardneal requested a review from a team as a code owner March 1, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant