Skip to content

Commit

Permalink
[build] bootstrap a local .\bin\dotnet\ with .NET Workloads
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jonathanpeppers committed Mar 17, 2021
1 parent 7115ced commit 5547a58
Show file tree
Hide file tree
Showing 21 changed files with 196 additions and 107 deletions.
17 changes: 14 additions & 3 deletions .nuspec/package.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
param ($configuration)
param ([string] $configuration = 'Debug')

dotnet pack $PSScriptRoot\..\Microsoft.Maui-net6.sln `
$ext = if ($IsWindows) { ".exe" } else { "" }
$dotnet = Join-Path $PSScriptRoot ../bin/dotnet/dotnet$ext
$sln = Join-Path $PSScriptRoot ../Microsoft.Maui-net6.sln
$artifacts = Join-Path $PSScriptRoot ../artifacts

if (-not (Test-Path $dotnet))
{
$csproj = Join-Path $PSScriptRoot ../src/DotNet/DotNet.csproj
& dotnet build $csproj -bl:$artifacts/dotnet.binlog
}

& $dotnet pack $sln `
-c:$configuration `
-p:SymbolPackageFormat=snupkg `
-bl:$PSScriptRoot/../artifacts/maui.binlog
-bl:$artifacts/maui.binlog
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project>
<Import Project="eng\Version.props" />
<PropertyGroup>
<_MauiBuildTasksLocation>$(_MauiBuildTasksLocation)</_MauiBuildTasksLocation>
<_MauiBuildTasksLocation Condition="'$(_MauiBuildTasksLocation)' == ''">$(MSBuildThisFileDirectory).nuspec\</_MauiBuildTasksLocation>
Expand Down
9 changes: 9 additions & 0 deletions eng/Version.props
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>
6 changes: 4 additions & 2 deletions eng/pipelines/common/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ steps:
provisioning_script: $(provisionator.path)
provisioning_extra_args: $(provisionator.extraArguments)

- template: dotnet-install.yml
- powershell: |
& dotnet build src\DotNet\DotNet.csproj -bl:${{ parameters.artifactsTargetFolder }}\$(BuildConfiguration)-dotnet.binlog
displayName: install .NET
- powershell: |
$(System.DefaultWorkingDirectory)/build.ps1 --target provision --TeamProject="$(System.TeamProject)"
Expand Down Expand Up @@ -67,7 +69,7 @@ steps:
displayName: 'Copy Files dlls'
inputs:
Contents: |
**/bin/**/*.dll
src/**/bin/**/*.dll
TargetFolder: ${{ parameters.artifactsTargetFolder }}

- task: PublishBuildArtifacts@1
Expand Down
27 changes: 0 additions & 27 deletions eng/pipelines/common/dotnet-install.yml

This file was deleted.

15 changes: 0 additions & 15 deletions eng/pipelines/common/variables-net6.yml

This file was deleted.

48 changes: 5 additions & 43 deletions eng/pipelines/handlers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ schedules:

variables:
- template: /eng/pipelines/common/variables.yml
- template: /eng/pipelines/common/variables-net6.yml
- name: LogDirectory
value: $(Build.ArtifactStagingDirectory)/logs
- name: provisionator.xcode
Expand All @@ -55,6 +54,8 @@ variables:
value: '$(System.DefaultWorkingDirectory)/eng/provisioning/provisioning.csx'
- name: provisionator.extraArguments
value: '--v'
- name: DotNet.Path
value: $(System.DefaultWorkingDirectory)/bin/dotnet/dotnet

parameters:
- name: BuildEverything
Expand Down Expand Up @@ -145,27 +146,7 @@ stages:
pool:
name: ${{ BuildPlatform.poolName }}
vmImage: ${{ BuildPlatform.vmImage }}
${{ if eq(BuildPlatform.name, 'macos') }}:
variables:
DotNet.Root: /usr/local/share/dotnet/
DotNet.Tools: ~/.dotnet/tools
steps:
- ${{ if eq(BuildPlatform.name, 'macos') }}:
- task: UseDotNet@2
displayName: install .NET Core 3.1
inputs:
version: 3.1.x
installationPath: $(DotNet.Root)
- template: common/dotnet-install.yml
- pwsh: |
dotnet tool install --global boots
boots ${{ BuildPlatform.bootsAndroid }}
boots ${{ BuildPlatform.bootsiOS }}
if ('${{ BuildPlatform.bootsMacCatalyst }}' -ne '') {
boots ${{ BuildPlatform.bootsMacCatalyst }}
}
displayName: install .NET workloads
errorActionPreference: stop
- ${{ if eq(BuildPlatform.name, 'macos') }}:
- bash: |
set -x
Expand Down Expand Up @@ -210,27 +191,7 @@ stages:
pool:
name: ${{ BuildPlatform.poolName }}
vmImage: ${{ BuildPlatform.vmImage }}
${{ if eq(BuildPlatform.name, 'macos') }}:
variables:
DotNet.Root: /usr/local/share/dotnet/
DotNet.Tools: ~/.dotnet/tools
steps:
- ${{ if eq(BuildPlatform.name, 'macos') }}:
- task: UseDotNet@2
displayName: install .NET Core 3.1
inputs:
version: 3.1.x
installationPath: $(DotNet.Root)
- template: common/dotnet-install.yml
- pwsh: |
dotnet tool install --global boots
boots ${{ BuildPlatform.bootsAndroid }}
boots ${{ BuildPlatform.bootsiOS }}
if ('${{ BuildPlatform.bootsMacCatalyst }}' -ne '') {
boots ${{ BuildPlatform.bootsMacCatalyst }}
}
displayName: install .NET workloads
errorActionPreference: stop
- ${{ if eq(BuildPlatform.name, 'macos') }}:
- bash: |
set -x
Expand All @@ -240,8 +201,9 @@ stages:
cat ~/Library/Preferences/Xamarin/Settings.plist || true
displayName: configure vsmac xcode
- pwsh: |
dotnet build Microsoft.Maui.BuildTasks-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration)-buildtasks.binlog
dotnet build Microsoft.Maui-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration).binlog
& dotnet build src\DotNet\DotNet.csproj -bl:$(LogDirectory)\$(BuildConfiguration)-dotnet.binlog
& $(DotNet.Path) build Microsoft.Maui.BuildTasks-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration)-buildtasks.binlog
& $(DotNet.Path) build Microsoft.Maui-net6.sln -c $(BuildConfiguration) -bl:$(LogDirectory)/$(BuildConfiguration).binlog
displayName: build samples
errorActionPreference: stop
- task: PublishBuildArtifacts@1
Expand Down
3 changes: 1 addition & 2 deletions src/Compatibility/Core/src/Compatibility-net6.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-android</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
<RootNamespace>Microsoft.Maui.Controls.Compatibility</RootNamespace>
<AssemblyName>Microsoft.Maui.Controls.Compatibility</AssemblyName>
<Nullable>disable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net6.0-android;net6.0-maccatalyst;net6.0-ios</TargetFrameworks>
<RuntimeIdentifier Condition="'$(TargetFramework)' == 'net6.0-ios'">ios-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">maccatalyst-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<RootNamespace>Maui.Controls.Sample</RootNamespace>
<AssemblyName>Maui.Controls.Sample</AssemblyName>
<IsPackable>false</IsPackable>
Expand Down
3 changes: 1 addition & 2 deletions src/Controls/src/Core/Controls.Core-net6.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<RootNamespace>Microsoft.Maui.Controls</RootNamespace>
<AssemblyName>Microsoft.Maui.Controls</AssemblyName>
<Nullable>disable</Nullable>
Expand Down
3 changes: 1 addition & 2 deletions src/Controls/src/Xaml/Controls.Xaml-net6.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<AssemblyName>Microsoft.Maui.Controls.Xaml</AssemblyName>
<RootNamespace>Microsoft.Maui.Controls.Xaml</RootNamespace>
<NoWarn>$(NoWarn);CA2200;</NoWarn>
Expand Down
19 changes: 18 additions & 1 deletion src/Controls/tests/Xaml.UnitTests/MSBuild/MSBuildTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Xml.Linq;
using Mono.Cecil;
Expand Down Expand Up @@ -184,9 +185,25 @@ void onData(object s, DataReceivedEventArgs e)
}
};

var ext = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "";
var dotnet = IOPath.Combine(testDirectory, "..", "..", "..", "..", "..", "..", "..", "bin", "dotnet", $"dotnet{ext}");
if (!File.Exists (dotnet))
{
Console.WriteLine($"Using 'dotnet', did not find: {dotnet}");

// If we don't have .\bin\dotnet\dotnet, try the system one
dotnet = "dotnet";
}
else
{
dotnet = IOPath.GetFullPath(dotnet);

Console.WriteLine($"Using '{dotnet}'");
}

var psi = new ProcessStartInfo
{
FileName = "dotnet",
FileName = dotnet,
Arguments = $"build -v:{verbosity} -nologo {projectFile} -t:{target} -bl {additionalArgs}",
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
Expand Down
3 changes: 1 addition & 2 deletions src/Core/src/Core-net6.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT'">$(TargetFrameworks);net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<RootNamespace>Microsoft.Maui</RootNamespace>
<AssemblyName>Microsoft.Maui</AssemblyName>
<Nullable>enable</Nullable>
Expand Down
3 changes: 3 additions & 0 deletions src/DotNet/Dependencies/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="../../../eng/Version.props" />
</Project>
1 change: 1 addition & 0 deletions src/DotNet/Dependencies/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Project />
15 changes: 15 additions & 0 deletions src/DotNet/Dependencies/Packs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<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)]" />
</ItemGroup>
</Project>
10 changes: 10 additions & 0 deletions src/DotNet/Dependencies/Workloads.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageDownload Include="Microsoft.NET.Workload.Android" Version="[$(MicrosoftAndroidSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.MacCatalyst" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.iOS" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
</ItemGroup>
</Project>
Loading

0 comments on commit 5547a58

Please sign in to comment.