-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[build] bootstrap a local .\bin\dotnet\ with .NET Workloads
Based on: https://github.com/jonathanpeppers/maui-workload This adds a new `DotNet.csproj` that provisions a local .NET 6 install into `.\bin\dotnet\`. Next, it uses versions defined in `eng/Versions.props` as required by .NET version bumping infrastructure (called Darc): <Project> <PropertyGroup> <MicrosoftNETSdkPackageVersion>6.0.100-preview.2.21155.3</MicrosoftNETSdkPackageVersion> <MicrosoftAndroidSdkPackageVersion>11.0.200-ci.main.148</MicrosoftAndroidSdkPackageVersion> <MicrosoftMacCatalystSdkPackageVersion>14.3.100-ci.main.337</MicrosoftMacCatalystSdkPackageVersion> <MicrosoftiOSSdkPackageVersion>14.4.100-ci.main.1192</MicrosoftiOSSdkPackageVersion> </PropertyGroup> </Project> Next, we can use these versions to consume NuGet packages for workloads: <PackageDownload Include="Microsoft.NET.Workload.Android" Version="[$(MicrosoftAndroidSdkPackageVersion)]" /> <PackageDownload Include="Microsoft.NET.Workload.MacCatalyst" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" /> <PackageDownload Include="Microsoft.NET.Workload.iOS" Version="[$(MicrosoftiOSSdkPackageVersion)]" /> Then the other packs they depend on: <PackageDownload Include="Microsoft.Android.Ref" Version="[$(MicrosoftAndroidSdkPackageVersion)]" /> <PackageDownload Include="Microsoft.Android.Sdk.win-x64" Version="[$(MicrosoftAndroidSdkPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('windows'))" /> <PackageDownload Include="Microsoft.Android.Sdk.osx-x64" Version="[$(MicrosoftAndroidSdkPackageVersion)]" Condition="$([MSBuild]::IsOSPlatform('osx'))" /> <PackageDownload Include="Microsoft.Android.Sdk.BundleTool" Version="[$(MicrosoftAndroidSdkPackageVersion)]" /> <PackageDownload Include="Microsoft.MacCatalyst.Ref" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" /> <PackageDownload Include="Microsoft.MacCatalyst.Sdk" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" /> <PackageDownload Include="Microsoft.iOS.Ref" Version="[$(MicrosoftiOSSdkPackageVersion)]" /> <PackageDownload Include="Microsoft.iOS.Sdk" Version="[$(MicrosoftiOSSdkPackageVersion)]" /> After doing this, I can build .NET 6 projects with: > .\bin\dotnet\dotnet.exe build .\src\Controls\samples\Controls.Sample.SingleProject\Maui.Controls.Sample.SingleProject.csproj I can even build MacCatalyst apps on Windows! I updated `build.cake` so the following builds for .NET 6 and opens Visual Studio: > dotnet cake --target=VS-NET6 This is the equivalent of these commands if you want to run them individually: dotnet build src\DotNet\DotNet.csproj .\bin\dotnet\dotnet build Microsoft.Maui.BuildTasks-net6.sln .\bin\dotnet\dotnet build Microsoft.Maui-net6.sln .\eng\dogfood.ps1 ~~ Other Changes ~~ * Rework CI setup to use .\bin\dotnet\dotnet * We don't need boots or URLs anymore * Fixed `MSBuildTests` to use .\bin\dotnet\dotnet if found and fall back to the system `dotnet` * Moved `.nuspec\package.ps1` to `eng\package.ps1` ~~ What problems does this solve? ~~ * MacCatalyst builds on Windows! (offline build that checks C#) * Building Maui always gets you the right things installed. * Maui becoming a .NET workload will be a breeze. We can copy files into `.\bin\dotnet\sdk-manifests` and `.\bin\dotnet\packs`. * We can use Darc to bump dependencies within .NET: https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md
- Loading branch information
1 parent
6402f5c
commit 64f93dc
Showing
29 changed files
with
361 additions
and
129 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project> | ||
<!--Package versions--> | ||
<PropertyGroup> | ||
<MicrosoftNETSdkPackageVersion>6.0.100-preview.2.21155.3</MicrosoftNETSdkPackageVersion> | ||
<MicrosoftAndroidSdkPackageVersion>11.0.200-ci.main.148</MicrosoftAndroidSdkPackageVersion> | ||
<MicrosoftMacCatalystSdkPackageVersion>14.3.100-ci.main.337</MicrosoftMacCatalystSdkPackageVersion> | ||
<MicrosoftiOSSdkPackageVersion>14.4.100-ci.main.1192</MicrosoftiOSSdkPackageVersion> | ||
</PropertyGroup> | ||
</Project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<# | ||
.SYNOPSIS | ||
*Windows-only* Launches Visual Studio with environment variables to use the local ./bin/dotnet/dotnet.exe. | ||
.DESCRIPTION | ||
*Windows-only* Launches Visual Studio with environment variables to use the local ./bin/dotnet/dotnet.exe. | ||
Script based on: | ||
https://github.com/dotnet/runtime/blob/1be117d8e7c0cd29ebc55cbcff2a7fa70604ed39/eng/build.ps1#L186-L208 | ||
https://github.com/dotnet/runtime/blob/1be117d8e7c0cd29ebc55cbcff2a7fa70604ed39/eng/common/tools.ps1#L109 | ||
.PARAMETER vs | ||
The path to Visual Studio, defaults to: | ||
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe". | ||
.PARAMETER sln | ||
The path to a .sln or .project file, defaults to "Microsoft.Maui-net6.sln". | ||
.PARAMETER modify | ||
Modify the environment variables in the current session. This would | ||
allow the "dotnet" command to work instead of ".\bin\dotnet\dotnet". | ||
However, it would be good to do this in a new terminal session, | ||
since you would have trouble running "dotnet build" if it needs to | ||
provision .NET 6 and the iOS/Android workloads again. | ||
.EXAMPLE | ||
PS> .\scripts\dogfood.ps1 | ||
.EXAMPLE | ||
PS> .\scripts\dogfood.ps1 -vs "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe" | ||
.EXAMPLE | ||
PS> .\scripts\dogfood.ps1 -sln .\path\to\MySolution.sln | ||
#> | ||
|
||
param( | ||
[string]$vs = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe", | ||
[string]$sln, | ||
[switch]$modify | ||
) | ||
|
||
$dotnet=Join-Path $PSScriptRoot ../bin/dotnet/ | ||
$dotnet=(Get-Item $dotnet).FullName | ||
|
||
if (-Not $sln) { | ||
$sln=Join-Path $PSScriptRoot ../Microsoft.Maui-net6.sln | ||
$sln=(Get-Item $sln).FullName | ||
} | ||
|
||
# Modify global.json, so the IDE can load | ||
$globaljson = Join-Path $PSScriptRoot ../global.json | ||
[xml] $xml = Get-Content (Join-Path $PSScriptRoot Version.props) | ||
$json = Get-Content $globaljson | ConvertFrom-Json | ||
$json | Add-Member sdk (New-Object -TypeName PSObject) -Force | ||
$json.sdk | Add-Member version $xml.Project.PropertyGroup.MicrosoftNETSdkPackageVersion -Force | ||
$json | ConvertTo-Json | Set-Content $globaljson | ||
|
||
# NOTE: I've not found a better way to do this | ||
# see: https://github.com/PowerShell/PowerShell/issues/3316 | ||
$oldDOTNET_INSTALL_DIR=$env:DOTNET_INSTALL_DIR | ||
$oldDOTNET_ROOT=$env:DOTNET_ROOT | ||
$oldDOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR | ||
$oldDOTNET_MULTILEVEL_LOOKUP=$env:DOTNET_MULTILEVEL_LOOKUP | ||
$oldMSBuildEnableWorkloadResolver=$env:MSBuildEnableWorkloadResolver | ||
$old_ExcludeMauiProjectCapability=$env:_ExcludeMauiProjectCapability | ||
$oldPATH=$env:PATH | ||
|
||
try { | ||
$env:DOTNET_INSTALL_DIR=$dotnet | ||
|
||
# This tells .NET to use the bootstrapped runtime | ||
$env:DOTNET_ROOT=$env:DOTNET_INSTALL_DIR | ||
|
||
# This tells MSBuild to load the SDK from the directory of the bootstrapped SDK | ||
$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$env:DOTNET_ROOT | ||
|
||
# This tells .NET not to go looking for .NET in other places | ||
$env:DOTNET_MULTILEVEL_LOOKUP=0 | ||
|
||
# This enables workload support inside the IDE | ||
$env:MSBuildEnableWorkloadResolver=$true | ||
|
||
# This disables the Maui @(ProjectCapability), a temporary workaround for 16.9 | ||
$env:_ExcludeMauiProjectCapability=$true | ||
|
||
# Put our local dotnet.exe on PATH first so Visual Studio knows which one to use | ||
$env:PATH=($env:DOTNET_ROOT + ";" + $env:PATH) | ||
|
||
# Launch VS | ||
& "$vs" "$sln" | ||
} finally { | ||
if (-Not $modify) { | ||
$env:DOTNET_INSTALL_DIR = $oldDOTNET_INSTALL_DIR | ||
$env:DOTNET_ROOT=$oldDOTNET_ROOT | ||
$env:DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=$oldDOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR | ||
$env:DOTNET_MULTILEVEL_LOOKUP=$oldDOTNET_MULTILEVEL_LOOKUP | ||
$env:MSBuildEnableWorkloadResolver=$oldMSBuildEnableWorkloadResolver | ||
$env:_ExcludeMauiProjectCapability=$old_ExcludeMauiProjectCapability | ||
$env:PATH=$oldPATH | ||
} | ||
} | ||
|
||
exit 0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
param ([string] $configuration = 'Debug') | ||
|
||
$artifacts = Join-Path $PSScriptRoot ../artifacts | ||
|
||
# Bootstrap .\bin\dotnet\ | ||
$csproj = Join-Path $PSScriptRoot ../src/DotNet/DotNet.csproj | ||
& dotnet build $csproj -bl:$artifacts/dotnet-$configuration.binlog | ||
|
||
$ext = if ($IsWindows) { ".exe" } else { "" } | ||
$dotnet = Join-Path $PSScriptRoot ../bin/dotnet/dotnet$ext | ||
$sln = Join-Path $PSScriptRoot ../Microsoft.Maui-net6.sln | ||
|
||
# Build with .\bin\dotnet\dotnet.exe | ||
& $dotnet pack $sln ` | ||
-c:$configuration ` | ||
-p:SymbolPackageFormat=snupkg ` | ||
-bl:$artifacts/maui-$configuration.binlog |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.