Repository navigation
[Unhandled Exception]: ArgumentNullException - Parameter "projectFile" cannot be null #13416
Copy link
Copy link
Closed
Closed
Copy link
Labels
Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Issues impacting the diagnosability of builds, including logging and clearer error messages.triaged
Description
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
Reacted by Krzysztof Wicher
Metadata
Metadata
Assignees
Labels
Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Issues impacting the diagnosability of builds, including logging and clearer error messages.triaged
Activity
MichalPavlik commentedon Mar 19, 2026
Triage: This should be already fixed on main via PR #13179, which added a null-coalescing fallback.
MichalPavlik commentedon Mar 19, 2026
Could you please try 18.5 insiders version to check if you can repro the issue?
prozolic commentedon Mar 22, 2026
I also encountered the same msbuild error after updating dotnet/runtime to the latest commit.
Once I updated Visual Studio to the Insider version, I can build and debug successfully in Visual Studio.
AR-May commentedon Mar 24, 2026
@Kevinf63 is your issue fixed in 18.5 insiders version?
YuliiaKovalova commentedon Mar 25, 2026
@cincuranet has the same problem and he claims it still repros in vs18.5
cincuranet commentedon Mar 25, 2026
@YuliiaKovalova I'm on
VisualStudio.18.Release/18.4.1+11612.150, so not 18.5.Anyway, here are some binlogs from the crash when building dotnet/runtime in case somebody wants to double check.
YuliiaKovalova commentedon Mar 25, 2026
Ok, it's related to NET task host usage, https://github.com/dotnet/arcade/blame/763f00f88ed4142b49c7ba46457597a69964707a/src/Microsoft.DotNet.Arcade.Sdk/tools/Version.targets
MSBuild throws because it receives the wrong path to NET host Path, and it comes from
RuntimeIdentifierGraphPathsinceNetCoreSdkRootreturns null@ViktorHofer fixed it in scope of 7744bc9
YuliiaKovalova commentedon Mar 25, 2026
@ViktorHofer , the other thing to consider when you push tasks out of proc is:
The project being built (Microsoft.Extensions.FileSystemGlobbing.csproj) is being built inside the Visual Studio MSBuild host (not via the .NET SDK CLI). The NetCoreSdkRoot property is only injected by the .NET SDK's Microsoft.dotnet.targets toolchain - it is not set in this VS-hosted build context.
cc: @baronfel , @rainersigwald
ViktorHofer commentedon Mar 25, 2026
Same applies to the
RuntimeIdentifierGraphPathproperty, doesn't it? But yes, Runtime="NET" support currently only works with the Microsoft.NET.Sdk: #12895. Given that the project imports the Microsoft.NET.Sdk, it should totally work with desktop build, inside VS.How is
NetCoreSdkRootnull? Runtime depends on this minimum SDK version and that one has theNetCoreSdkRootproperty: https://github.com/dotnet/runtime/blob/b5c98ef234c03e4d284bfd2f2c60ca982550fb30/global.json#L3.Looking at the binlogs,
NetCoreSdkRootis set:EDIT: I guess it's probably just msbuild that isn't new enough in that VS version and doesn't respect
NetCoreSdkRoot.Additionally, Arcade imports the Sdk.BundledVersions.props file explicitly so even on non Microsoft.NET.Sdk project types, Runtime="NET" should work: https://github.com/dotnet/arcade/blob/291fa0852f49d984f72da872f52e9b492447d179/src/Microsoft.DotNet.Arcade.Sdk/tools/BuildTasks.props#L4-L12
ViktorHofer commentedon Mar 25, 2026
BTW the binlogs that @cincuranet shared appear to be design time build failures. I wonder what could be different there. Also, should the
GenerateResxSourcearcade task run in a design time build?YuliiaKovalova commentedon Mar 25, 2026
yes, locally i hit this issue in DTB when it was trying to execute
GenerateResxSourceYuliiaKovalova commentedon Mar 25, 2026
yes, it should, but it doesn't :)
it's evident from the screenshot since we fallback to RuntimeIdentifierGraphPath
ViktorHofer commentedon Mar 25, 2026
OK I'm confused. Is there anything to do here?
ViktorHofer commentedon Mar 25, 2026
I guess we should double check whether Runtime="NET" support works as expected in design time builds. From the binlog, I see that design time builds import the Microsoft.NET.Sdk from the expected location and the property is available. I think this is just some sort of torn state when using vs18.4. This should naturally go away when everyone is on vs18.5.
ViktorHofer commentedon Mar 25, 2026
@cincuranet FWIW please try again after updating to VS 18.5 which has my fix.
ViktorHofer commentedon Mar 25, 2026
I briefly chatted with @YuliiaKovalova offline about this. I think the screenshot above is misleading as it probably shows a newer state of the msbuild code base and not what is inside vs18.4 (which is the version that was used to repro).
For internal customers (Arcade repos):
Since dotnet/dotnet@4e09105 got merged, arcadified repos now require at least VS 18.5. This of course only applies when building with desktop msbuild (inside VS). It doesn't affect CI or so.
I could have communicated this more broadly but this should only be a point in time issue and most of us are already on 18.5 or even 18.6.
Btw, the actual issue described in the title got fixed with #13179. We now log a better diagnostic.
TL;DR: Nothing to do here. We except customers to update to VS >= 18.5 to fix this. We can't service this in 18.4 as the servicing window is too narrow.
Kevinf63 commentedon Apr 3, 2026
After installing Enterprise Insiders [11626.173], adding the GitVersion.MsBuild package to a .NET Standard 2.0 package with the yaml configuration per above now builds successfully. Likely a combination of the Insiders build suggested and arturcic:feature/msbuild-task #4750 present from GitVersion v6.5.1+.
Further testing
A Similar
System.ArgumentNullException: Parameter "projectFile" cannot be nullcould be seen on VS26 v18.4.3 with a project targeting .NET 8 with the same GitVersion nuget package. After installing VS26 Enterprise Insiders [11626.173], building that .NET 8 project with the followingglobal.json:{ "sdk": { "rollForward": "latestFeature", "version": "8.0.416" } }Returns
MSBUILD : error : SDK version 8 is below the minimum required version of 10. The .NET Runtime Task Host is supported only when using .NET SDK 10.0.100-rc1 or later.While maintaining the project's .NET 8 SDK target, changing the
global.jsonto the following builds successfully:{ "sdk": { "rollForward": "latestFeature", "version": "10.0.201" } }