Skip to content

Commit 5547a58

Browse files
[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! ~~ 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` ~~ TODO ~~ This obviously will change the Maui team's workflow, so: * We need a script (or something) to launch VS Windows configured to use the `.\bin\dotnet\dotnet.exe`, similar to: https://github.com/jonathanpeppers/maui-workload/blob/main/scripts/dogfood.ps1 * Need VS Mac support * Need docs explaining how to do local dev, etc. ~~ 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
1 parent 7115ced commit 5547a58

File tree

21 files changed

+196
-107
lines changed

21 files changed

+196
-107
lines changed

.nuspec/package.ps1

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
param ($configuration)
1+
param ([string] $configuration = 'Debug')
22

3-
dotnet pack $PSScriptRoot\..\Microsoft.Maui-net6.sln `
3+
$ext = if ($IsWindows) { ".exe" } else { "" }
4+
$dotnet = Join-Path $PSScriptRoot ../bin/dotnet/dotnet$ext
5+
$sln = Join-Path $PSScriptRoot ../Microsoft.Maui-net6.sln
6+
$artifacts = Join-Path $PSScriptRoot ../artifacts
7+
8+
if (-not (Test-Path $dotnet))
9+
{
10+
$csproj = Join-Path $PSScriptRoot ../src/DotNet/DotNet.csproj
11+
& dotnet build $csproj -bl:$artifacts/dotnet.binlog
12+
}
13+
14+
& $dotnet pack $sln `
415
-c:$configuration `
516
-p:SymbolPackageFormat=snupkg `
6-
-bl:$PSScriptRoot/../artifacts/maui.binlog
17+
-bl:$artifacts/maui.binlog

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project>
2+
<Import Project="eng\Version.props" />
23
<PropertyGroup>
34
<_MauiBuildTasksLocation>$(_MauiBuildTasksLocation)</_MauiBuildTasksLocation>
45
<_MauiBuildTasksLocation Condition="'$(_MauiBuildTasksLocation)' == ''">$(MSBuildThisFileDirectory).nuspec\</_MauiBuildTasksLocation>

eng/Version.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
<!--Package versions-->
3+
<PropertyGroup>
4+
<MicrosoftNETSdkPackageVersion>6.0.100-preview.2.21155.3</MicrosoftNETSdkPackageVersion>
5+
<MicrosoftAndroidSdkPackageVersion>11.0.200-ci.main.148</MicrosoftAndroidSdkPackageVersion>
6+
<MicrosoftMacCatalystSdkPackageVersion>14.3.100-ci.main.337</MicrosoftMacCatalystSdkPackageVersion>
7+
<MicrosoftiOSSdkPackageVersion>14.4.100-ci.main.1192</MicrosoftiOSSdkPackageVersion>
8+
</PropertyGroup>
9+
</Project>

eng/pipelines/common/build-windows.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ steps:
1616
provisioning_script: $(provisionator.path)
1717
provisioning_extra_args: $(provisionator.extraArguments)
1818

19-
- template: dotnet-install.yml
19+
- powershell: |
20+
& dotnet build src\DotNet\DotNet.csproj -bl:${{ parameters.artifactsTargetFolder }}\$(BuildConfiguration)-dotnet.binlog
21+
displayName: install .NET
2022
2123
- powershell: |
2224
$(System.DefaultWorkingDirectory)/build.ps1 --target provision --TeamProject="$(System.TeamProject)"
@@ -67,7 +69,7 @@ steps:
6769
displayName: 'Copy Files dlls'
6870
inputs:
6971
Contents: |
70-
**/bin/**/*.dll
72+
src/**/bin/**/*.dll
7173
TargetFolder: ${{ parameters.artifactsTargetFolder }}
7274

7375
- task: PublishBuildArtifacts@1

eng/pipelines/common/dotnet-install.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

eng/pipelines/common/variables-net6.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

eng/pipelines/handlers.yml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ schedules:
4646

4747
variables:
4848
- template: /eng/pipelines/common/variables.yml
49-
- template: /eng/pipelines/common/variables-net6.yml
5049
- name: LogDirectory
5150
value: $(Build.ArtifactStagingDirectory)/logs
5251
- name: provisionator.xcode
@@ -55,6 +54,8 @@ variables:
5554
value: '$(System.DefaultWorkingDirectory)/eng/provisioning/provisioning.csx'
5655
- name: provisionator.extraArguments
5756
value: '--v'
57+
- name: DotNet.Path
58+
value: $(System.DefaultWorkingDirectory)/bin/dotnet/dotnet
5859

5960
parameters:
6061
- name: BuildEverything
@@ -145,27 +146,7 @@ stages:
145146
pool:
146147
name: ${{ BuildPlatform.poolName }}
147148
vmImage: ${{ BuildPlatform.vmImage }}
148-
${{ if eq(BuildPlatform.name, 'macos') }}:
149-
variables:
150-
DotNet.Root: /usr/local/share/dotnet/
151-
DotNet.Tools: ~/.dotnet/tools
152149
steps:
153-
- ${{ if eq(BuildPlatform.name, 'macos') }}:
154-
- task: UseDotNet@2
155-
displayName: install .NET Core 3.1
156-
inputs:
157-
version: 3.1.x
158-
installationPath: $(DotNet.Root)
159-
- template: common/dotnet-install.yml
160-
- pwsh: |
161-
dotnet tool install --global boots
162-
boots ${{ BuildPlatform.bootsAndroid }}
163-
boots ${{ BuildPlatform.bootsiOS }}
164-
if ('${{ BuildPlatform.bootsMacCatalyst }}' -ne '') {
165-
boots ${{ BuildPlatform.bootsMacCatalyst }}
166-
}
167-
displayName: install .NET workloads
168-
errorActionPreference: stop
169150
- ${{ if eq(BuildPlatform.name, 'macos') }}:
170151
- bash: |
171152
set -x
@@ -210,27 +191,7 @@ stages:
210191
pool:
211192
name: ${{ BuildPlatform.poolName }}
212193
vmImage: ${{ BuildPlatform.vmImage }}
213-
${{ if eq(BuildPlatform.name, 'macos') }}:
214-
variables:
215-
DotNet.Root: /usr/local/share/dotnet/
216-
DotNet.Tools: ~/.dotnet/tools
217194
steps:
218-
- ${{ if eq(BuildPlatform.name, 'macos') }}:
219-
- task: UseDotNet@2
220-
displayName: install .NET Core 3.1
221-
inputs:
222-
version: 3.1.x
223-
installationPath: $(DotNet.Root)
224-
- template: common/dotnet-install.yml
225-
- pwsh: |
226-
dotnet tool install --global boots
227-
boots ${{ BuildPlatform.bootsAndroid }}
228-
boots ${{ BuildPlatform.bootsiOS }}
229-
if ('${{ BuildPlatform.bootsMacCatalyst }}' -ne '') {
230-
boots ${{ BuildPlatform.bootsMacCatalyst }}
231-
}
232-
displayName: install .NET workloads
233-
errorActionPreference: stop
234195
- ${{ if eq(BuildPlatform.name, 'macos') }}:
235196
- bash: |
236197
set -x
@@ -240,8 +201,9 @@ stages:
240201
cat ~/Library/Preferences/Xamarin/Settings.plist || true
241202
displayName: configure vsmac xcode
242203
- pwsh: |
243-
dotnet build Microsoft.Maui.BuildTasks-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration)-buildtasks.binlog
244-
dotnet build Microsoft.Maui-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration).binlog
204+
& dotnet build src\DotNet\DotNet.csproj -bl:$(LogDirectory)\$(BuildConfiguration)-dotnet.binlog
205+
& $(DotNet.Path) build Microsoft.Maui.BuildTasks-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration)-buildtasks.binlog
206+
& $(DotNet.Path) build Microsoft.Maui-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration).binlog
245207
displayName: build samples
246208
errorActionPreference: stop
247209
- task: PublishBuildArtifacts@1

src/Compatibility/Core/src/Compatibility-net6.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0-ios;net6.0-android</TargetFrameworks>
4-
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
3+
<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
54
<RootNamespace>Microsoft.Maui.Controls.Compatibility</RootNamespace>
65
<AssemblyName>Microsoft.Maui.Controls.Compatibility</AssemblyName>
76
<Nullable>disable</Nullable>

src/Controls/samples/Controls.Sample.SingleProject/Maui.Controls.Sample.SingleProject.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
4-
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
3+
<TargetFrameworks>net6.0-android;net6.0-maccatalyst;net6.0-ios</TargetFrameworks>
54
<RuntimeIdentifier Condition="'$(TargetFramework)' == 'net6.0-ios'">ios-x64</RuntimeIdentifier>
65
<RuntimeIdentifier Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">maccatalyst-x64</RuntimeIdentifier>
76
<OutputType>Exe</OutputType>

src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
5-
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
4+
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
65
<RootNamespace>Maui.Controls.Sample</RootNamespace>
76
<AssemblyName>Maui.Controls.Sample</AssemblyName>
87
<IsPackable>false</IsPackable>

0 commit comments

Comments
 (0)