Issue Description
Updating to a NuGet package that does not support .NET Standard 2.0 (correction: see arturcic:feature/msbuild-task #4750), for example GitVersion.MsBuild 6.*, causes an unhandled exception error in MsBuild, instead of gracefully failing with steps to fix the problem , i.e. the .NET version (standard 2.0) of your project you are using does not support this NuGet package's SDK (.NET SDK 8+).
Steps to Reproduce
- Create a .NET Standard 2.0 project to be used as a NuGet package.
- Install GitVersion.MsBuild v5.12.0 NuGet package.
- Add gitversion.yml to root of project with first yaml example.
- Build successfully.
- Update to GitVersion.MsBuild v6.6.2 NuGet package.
- Update gitversion.yml in root of project with second yaml example.
- Observe output upon build.
GitVersion v5.12.0 yaml:
mode: Mainline
continuous-delivery-fallback-tag: preview
major-version-bump-message: "^(Merged PR \\d+: )?(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
minor-version-bump-message: "^(Merged PR \\d+: )?(feat)(\\([\\w\\s-]*\\))?:"
patch-version-bump-message: "^(Merged PR \\d+: )?(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
no-bump-message: "^(Merged PR \\d+: )?(none|skip)(\\([\\w\\s-]*\\))?:"
commit-message-incrementing: Enabled
branches: {}
ignore:
sha: []
merge-message-formats:
default: "^Merged (?:PR (?<PullRequestNumber>\\d+)):"
GitVersion v6.6.2 yaml:
workflow: TrunkBased/preview1
major-version-bump-message: "^(Merged PR \\d+: )?(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
minor-version-bump-message: "^(Merged PR \\d+: )?(feat)(\\([\\w\\s-]*\\))?:"
patch-version-bump-message: "^(Merged PR \\d+: )?(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:"
no-bump-message: "^(Merged PR \\d+: )?(none|skip)(\\([\\w\\s-]*\\))?:"
commit-message-incrementing: Enabled
merge-message-formats:
default: "^Merged (?:PR (?<PullRequestNumber>\\d+)):"
Actual Behavior
Rebuild started at 11:47...
1>------ Rebuild All started: Project: CM.Helpers.ScheduledService.Scoped, Configuration: Debug Any CPU ------
2>------ Rebuild All started: Project: CM.Helpers.ScheduledService.Abstractions, Configuration: Debug Any CPU ------
Restored C:\Users\kefinnegan\source\repos\CM.Helpers.TimedHostedService\CM.helpers.ScheduledService.Abstractions\CM.Helpers.ScheduledService.Abstractions.csproj (in 34 ms).
Restored C:\Users\kefinnegan\source\repos\CM.Helpers.TimedHostedService\CM.Helpers.ScheduledService.Scoped\CM.Helpers.ScheduledService.Scoped.csproj (in 34 ms).
1>MSBUILD : error : This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT https://aka.ms/msbuild/unhandled
1>MSBUILD : error : System.ArgumentNullException: Parameter "projectFile" cannot be null.
1>MSBUILD : error : at Microsoft.Build.Shared.ErrorUtilities.ThrowArgumentNull(String parameterName, String resourceName)
1>MSBUILD : error : at Microsoft.Build.Exceptions.InvalidProjectFileException..ctor(String projectFile, Int32 lineNumber, Int32 columnNumber, Int32 endLineNumber, Int32 endColumnNumber, String message, String errorSubcategory, String errorCode, String helpKeyword, Exception innerException)
1>MSBUILD : error : at Microsoft.Build.Exceptions.InvalidProjectFileException..ctor(String message, InvalidProjectFileException innerException)
1>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__24.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteBucket>d__19.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__18.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__13.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at Microsoft.Build.BackEnd.TargetEntry.<ProcessBucket>d__50.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__43.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at Microsoft.Build.BackEnd.TargetBuilder.<ProcessTargetStack>d__24.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>MSBUILD : error : at Microsoft.Build.BackEnd.TargetBuilder.<BuildTargets>d__11.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__67.MoveNext()
1>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
1>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.<RequestThreadProc>d__58.MoveNext()
2>MSBUILD : error : This is an unhandled exception in MSBuild -- PLEASE UPVOTE AN EXISTING ISSUE OR FILE A NEW ONE AT https://aka.ms/msbuild/unhandled
2>MSBUILD : error : System.ArgumentNullException: Parameter "projectFile" cannot be null.
2>MSBUILD : error : at Microsoft.Build.Shared.ErrorUtilities.ThrowArgumentNull(String parameterName, String resourceName)
2>MSBUILD : error : at Microsoft.Build.Exceptions.InvalidProjectFileException..ctor(String projectFile, Int32 lineNumber, Int32 columnNumber, Int32 endLineNumber, Int32 endColumnNumber, String message, String errorSubcategory, String errorCode, String helpKeyword, Exception innerException)
2>MSBUILD : error : at Microsoft.Build.Exceptions.InvalidProjectFileException..ctor(String message, InvalidProjectFileException innerException)
2>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<InitializeAndExecuteTask>d__24.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteBucket>d__19.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__18.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2>MSBUILD : error : at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteTask>d__13.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at Microsoft.Build.BackEnd.TargetEntry.<ProcessBucket>d__50.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at Microsoft.Build.BackEnd.TargetEntry.<ExecuteTarget>d__43.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at Microsoft.Build.BackEnd.TargetBuilder.<ProcessTargetStack>d__24.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2>MSBUILD : error : at Microsoft.Build.BackEnd.TargetBuilder.<BuildTargets>d__11.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2>MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.<BuildProject>d__67.MoveNext()
2>MSBUILD : error : --- End of stack trace from previous location where exception was thrown ---
2>MSBUILD : error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
2>MSBUILD : error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
2>MSBUILD : error : at Microsoft.Build.BackEnd.RequestBuilder.<RequestThreadProc>d__58.MoveNext()
========== Rebuild All: 0 succeeded, 2 failed, 0 skipped ==========
========== Rebuild completed at 11:47 and took 00.928 seconds ==========
Analysis
No response
Versions & Configurations
MSBuild version 18.4.0+6e61e96ac for .NET Framework
Version: 18.4.0.7901
Visual Studio 2026 Enterprise March 2026 Feature Update (Stable)
Version: 18.4.1
Instance: 04ecd097
Issue Description
Updating to a NuGet package
that does not support .NET Standard 2.0(correction: see arturcic:feature/msbuild-task #4750), for example GitVersion.MsBuild 6.*, causes an unhandled exception error in MsBuild, instead of gracefully failing with steps to fix the problem, i.e. the .NET version (standard 2.0) of your project you are using does not support this NuGet package's SDK (.NET SDK 8+).Steps to Reproduce
GitVersion v5.12.0 yaml:
GitVersion v6.6.2 yaml:
Actual Behavior
Analysis
No response
Versions & Configurations
MSBuild version 18.4.0+6e61e96ac for .NET Framework
Version: 18.4.0.7901
Visual Studio 2026 Enterprise March 2026 Feature Update (Stable)
Version: 18.4.1
Instance: 04ecd097