-
Notifications
You must be signed in to change notification settings - Fork 663
Bring back support for msbuild and Visual Studio #4750
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
Conversation
d27c90d to
98f9ecf
Compare
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.
Pull Request Overview
This PR re-enables MSBuild task support for .NET Framework builds when running on MSBuild version 18+ (Visual Studio 2026 and later), while maintaining compatibility with .NET Core builds. Previously, GitVersion tasks were completely disabled on .NET Framework; now they are conditionally enabled based on MSBuild version.
Key changes:
- Conditional task registration based on MSBuildRuntimeType with appropriate TaskFactory settings
- Updated disable condition to only block on MSBuild versions < 18 for Full Framework
- Refactored task execution to use method group references instead of lambda closures
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| GitVersion.MsBuild.targets | Splits UsingTask declarations for Full Framework (with TaskHostFactory) and Core runtime |
| GitVersion.MsBuild.props | Updates DisableGitVersionTask condition to allow MSBuild 18+ on Full Framework |
| GitVersionTasks.cs | Simplifies task executor invocation by passing task instances directly |
| ReferenceNameExtensions.cs | Adds ReSharper suppression comment for out parameter |
| ArtifactsMsBuildFullTest.cs | Adds MSBuild Full Framework testing when MSBuildToolVersion 11 is available |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
98f9ecf to
bd44563
Compare
|
This was tested on a windows machine running in a VM with a Visual Studio 2026 running a sample application (which is part of a git repo) and this piece of code: Console.WriteLine(GitVersionInformation.Sha);It compiled and when run get the sha of the commit. |
asbjornu
left a comment
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.
Although I don't use it anymore myself, it's awesome to have VS support back!
adapts msbuild tasks execution to use action with task parameter. removes net framework check on GitVersionTask. adds condition to msbuild targets.
This enabled testing the GitVersion.MsBuild with the full .NET Framework's version of msbuild
disables GitVersion task on .NET Framework with MSBuild < 18. updates conditions for UsingTask to use explicit string comparisons.
bd44563 to
9aa4c70
Compare
|



This pull request introduces several improvements to how MSBuild tasks are configured and executed for different .NET runtimes, as well as some code cleanups and minor refactorings. The main focus is on ensuring correct task registration and execution for both .NET Core and .NET Framework, improving maintainability, and removing outdated configuration. Below are the most important changes grouped by theme.
MSBuild Task Registration and Runtime Handling:
Updated
GitVersion.MsBuild.targetsto register MSBuild tasks (GetVersion,GenerateGitVersionInformation,WriteVersionInfoToBuildLog,UpdateAssemblyInfo) separately for .NET Core and .NET Framework, using appropriate conditions and task factories for each runtime. This ensures tasks are loaded correctly depending on the build environment.Removed the legacy property disabling GitVersion tasks on .NET Framework from
GitVersion.MsBuild.props, cleaning up the configuration and clarifying task enablement logic.Build Task Execution and Validation Improvements:
ArtifactsMsBuildFullTest.cs, added logic to check for a specificMSBuildToolVersionbefore running full framework tests, and refactored output validation to use a locally scopedfullSemVervariable for clarity and correctness. [1] [2]Code Refactoring and Cleanup:
Refactored
GitVersionTasks.csto simplify task execution by passing the task instance directly to the executor methods, improving readability and maintainability.Minor code comment and annotation improvements in
ReferenceNameExtensions.csto clarify out parameter usage.NOTE: this will work only when working on VS 2026 or msbuild 18. Lower versions are no supported.
Resolves #4130