You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Global properties are not passed into builds via SolutionCreator #367
When calling SolutionCreator.TryBuild and passing it an argument for globalProperties, I expected those properties to be applied to the build across all projects, not unlike the CLI command dotnet build -p:LangVersion=12.0.
However, I tried that in a test case sort of like this one. (The real test requires a lot of machinery that I can't duplicate here, unfortunately, but these are the important parts.)
[Theory][InlineData("12.0")][InlineData("13.0")][InlineData("latest")]publicvoidCanPassGlobalProperties(stringlangVersion){// This creates a SolutionCreator with a project in it, the details of which are not// particularly germane here.SolutionCreatorsolution=CreateTestSolution();solution.TryBuild(restore:true,globalProperties:newDictionary<string,string>(){{"LangVersion",langVersion}},outvar_,outvaroutput);// When, at this point, I interrogate the BuildOutput's events to see whether LangVersion was// ever set to, say, 12.0, I find that it wasn't.}
After looking at the source code for SolutionCreator.TryBuild, it appeared that the root cause is that globalProperties is only passed into the restore operation, but not the subsequent build operation, even though the underlying call to BuildHost.TryBuild supports it. Consequently, those global properties are being ignored.
I created PR #368 that attempts to fix the problem.
Upon further investigation, it doesn't appear that this is actually an issue. I'll need to dig a little further to figure out what mechanism is causing global properties to be passed in, but the fix I've proposed does not seem to be impacting the result. The global properties are actually there either way, just not where I expected them to be. I do find them in ProjectStartedEventArgs when I look at AllEvents in the BuildOutput.
Activity
alexthornton1 commentedon Sep 27, 2026
Upon further investigation, it doesn't appear that this is actually an issue. I'll need to dig a little further to figure out what mechanism is causing global properties to be passed in, but the fix I've proposed does not seem to be impacting the result. The global properties are actually there either way, just not where I expected them to be. I do find them in
ProjectStartedEventArgswhen I look atAllEventsin theBuildOutput.