-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[build] allow main to be built with a .NET 8 SDK #16508
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've been testing our latest .NET 8 release, and I noticed it was not currently possible to build dotnet/maui/main if you only have .NET 8 installed. The first issue to get past is `global.json`: "sdk": { "version": "7.0.200", "allowPrerelease": true, "rollForward": "latestMinor" } `latestMinor` does not allow it to "roll forward" to a .NET 8 SDK as it stops at any `7.0.x` version. I changed this to `major`, so it can use `8.x` or future versions. Alternatively we could completely remove the `sdk` block here, but I thought this was a reasonable change for now. The next error I got was: The "CheckForImplicitPackageReferenceOverrides" task could not be loaded from the assembly C:\Program Files\dotnet\sdk\8.0.100-preview.7.23376.3\Sdks\Microsoft.NET.Sdk\targets\..\tools\net8.0\Microsoft.NET.Build.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. This was quite confusing, but what I found was: * `dotnet cake` -> uses .NET 8 SDK from my system * A .NET 7 SDK is provisioned in `.\bin\dotnet\` * An `<Exec/>` task runs: * `.\bin\dotnet\dotnet restore src\DotNet\Dependencies\Workloads.csproj` which fails It looks like the issue is the outer/system .NET SDK passes the `$MSBuildSDKsPath` environment variable. This makes a .NET 7 SDK import .NET 8 MSBuild targets files -- and everything breaks. I could get past this error by clearing the env var. I also fixed the `.binlog` location for this command, so it goes in `artifacts/logs` now. The last issue I found was: ======================================== dotnet-pack-maui ======================================== Process terminated. The type initializer for 'System.Management.Automation.PSObject' threw an exception. at System.Environment.FailFast(System.String, System.Exception) at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String[], Int32) at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[]) System.TypeInitializationException: The type initializer for 'System.Management.Automation.PSObject' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. File name: 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at System.Management.Automation.PSObject..cctor() --- End of inner exception stack trace --- at System.Management.Automation.PSObject.get_Properties() at System.Management.Automation.HostUtilities.GetDollarProfile(String allUsersAllHosts, String allUsersCurrentHost, String currentUserAllHosts, String currentUserCurrentHost) at Microsoft.PowerShell.ConsoleHost.DoRunspaceInitialization(RunspaceCreationEventArgs args) at Microsoft.PowerShell.ConsoleHost.DoCreateRunspace(RunspaceCreationEventArgs args) at Microsoft.PowerShell.ConsoleHost.CreateRunspace(RunspaceCreationEventArgs runspaceCreationArgs) at Microsoft.PowerShell.ConsoleHost.DoRunspaceLoop(String initialCommand, Boolean skipProfiles, Collection`1 initialCommandArgs, Boolean staMode, String configurationName, String configurationFilePath) at Microsoft.PowerShell.ConsoleHost.Run(CommandLineParameterParser cpp, Boolean isPrestartWarned) at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText, Boolean issProvidedExternally) at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc) It appears that the `pwsh` .NET global tool basically doesn't run at all on .NET 8 yet? https://www.nuget.org/packages/PowerShell/7.3.6 This fails in this way (if you have .NET 8): dotnet pwsh eng/package.ps1 While this one succeeds: ./bin/dotnet/dotnet pwsh eng/package.ps1 I could fix this in MAUI's build by setting `ToolPath` in `dotnet.cake`: DotNetTool("pwsh", new DotNetToolSettings { ToolPath = dotnetPath, //... }); This makes the command use `./bin/dotnet/dotnet pwsh`, which works. This last change we might have to undo/revert on the `net8.0` branch until they fix the `pwsh` global tool.
Eilon
added
the
area-infrastructure
CI, Maestro / Coherency, upstream dependencies/versions
label
Aug 2, 2023
mattleibow
approved these changes
Aug 3, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-infrastructure
CI, Maestro / Coherency, upstream dependencies/versions
fixed-in-8.0.0-rc.1.9171
Look for this fix in 8.0.0-rc.1.9171
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been testing our latest .NET 8 release, and I noticed it was not currently possible to build dotnet/maui/main if you only have .NET 8 installed.
The first issue to get past is
global.json
:latestMinor
does not allow it to "roll forward" to a .NET 8 SDK as it stops at any7.0.x
version. I changed this tomajor
, so it can use8.x
or future versions. Alternatively we could completely remove thesdk
block here, but I thought this was a reasonable change for now.The next error I got was:
This was quite confusing, but what I found was:
dotnet cake
-> uses .NET 8 SDK from my systemA .NET 7 SDK is provisioned in
.\bin\dotnet\
An
<Exec/>
task runs:.\bin\dotnet\dotnet restore src\DotNet\Dependencies\Workloads.csproj
which failsIt looks like the issue is the outer/system .NET SDK passes the
$MSBuildSDKsPath
environment variable. This makes a .NET 7 SDK import .NET 8 MSBuild targets files -- and everything breaks. I could get past this error by clearing the env var. I also fixed the.binlog
location for this command, so it goes inartifacts/logs
now.The last issue I found was:
It appears that the
pwsh
.NET global tool basically doesn't run at all on .NET 8 yet?https://www.nuget.org/packages/PowerShell/7.3.6
This fails in this way (if you have .NET 8):
While this one succeeds:
I could fix this in MAUI's build by setting
ToolPath
indotnet.cake
:This makes the command use
./bin/dotnet/dotnet pwsh
, which works.This last change we might have to undo/revert on the
net8.0
branch until they fix thepwsh
global tool.