diff --git a/Directory.Build.props b/Directory.Build.props index 7c86fc6d1e..44bdecf415 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,6 +26,7 @@ false MonoAndroid10.0 netstandard2.0;netstandard2.1;MonoAndroid10.0 + snupkg diff --git a/README.md b/README.md index b0574ea4f7..78090812ab 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ dotnet build src\DotNet\DotNet.csproj # Builds the rest of Maui .\bin\dotnet\dotnet build Microsoft.Maui-net6.sln # (Windows-only) to launch Visual Studio -.\eng\dogfood.ps1 +dotnet cake --target=VS-DOGFOOD ``` To build & run .NET 6 sample apps, you will also need to use `.\bin\dotnet\dotnet`: diff --git a/build.cake b/build.cake index 5c145b7656..787b49a4ab 100644 --- a/build.cake +++ b/build.cake @@ -22,6 +22,8 @@ PowerShell: #addin "nuget:?package=Cake.Boots&version=1.0.4.600-preview1" #addin "nuget:?package=Cake.AppleSimulator&version=0.2.0" #addin "nuget:?package=Cake.FileHelpers&version=3.2.1" +#load "eng/cake/dotnet.cake" +#load "eng/cake/helpers.cake" ////////////////////////////////////////////////////////////////////// // TOOLS @@ -37,7 +39,7 @@ string agentName = EnvironmentVariable("AGENT_NAME", ""); bool isCIBuild = !String.IsNullOrWhiteSpace(agentName); string artifactStagingDirectory = EnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY", "."); string workingDirectory = EnvironmentVariable("SYSTEM_DEFAULTWORKINGDIRECTORY", "."); -var configuration = Argument("BUILD_CONFIGURATION", "Debug"); +var configuration = GetBuildVariable("BUILD_CONFIGURATION", GetBuildVariable("configuration", "DEBUG")); var target = Argument("target", "Default"); if(String.IsNullOrWhiteSpace(target)) @@ -237,26 +239,27 @@ Information ("iosSDK: {0}", iosSDK); // TASKS ////////////////////////////////////////////////////////////////////// -Task("Clean") - .Description("Deletes all the obj/bin directories") +Task("BuildUnitTests") + .IsDependentOn("BuildTasks") + .Description("Builds all necessary projects to run Unit Tests") .Does(() => { - List foldersToClean = new List(); - - foreach (var item in new [] {"obj", "bin"}) + try { - foreach(string f in System.IO.Directory.GetDirectories(".", item, SearchOption.AllDirectories)) - { - if(f.StartsWith(@".\bin") || f.StartsWith(@".\tools")) - continue; + var msbuildSettings = GetMSBuildSettings(); + var binaryLogger = new MSBuildBinaryLogSettings { + Enabled = isCIBuild + }; - // this is here as a safety check - if(!f.StartsWith(@".\src")) - continue; - - CleanDirectories(f); - } - } + msbuildSettings.BinaryLogger = binaryLogger; + binaryLogger.FileName = $"{artifactStagingDirectory}/Maui.Controls-{configuration}.binlog"; + MSBuild("./Microsoft.Maui.sln", msbuildSettings.WithRestore()); + } + catch(Exception) + { + if(IsRunningOnWindows()) + throw; + } }); Task("provision-macsdk") @@ -678,19 +681,6 @@ Task("provision") .IsDependentOn("provision-windowssdk") .IsDependentOn("provision-monosdk"); // always provision monosdk last otherwise CI might fail -Task("NuGetPack") - .Description("Build and Create Nugets").Does(()=> { - - var settings = new DotNetCoreToolSettings - { - DiagnosticOutput = true, - ArgumentCustomization = args => args.Append($"./eng/package.ps1 -configuration \"{configuration}\"") - }; - - DotNetCoreTool("pwsh", settings); - -});; - Task("provision-powershell").Does(()=> { var settings = new DotNetCoreToolSettings { @@ -728,144 +718,6 @@ Task("WriteGoogleMapsAPIKey") } }); -Task("BuildForNuget") - .IsDependentOn("BuildTasks") - .Description("Builds all necessary projects to create Nuget Packages") - .Does(() => -{ - try - { - var msbuildSettings = GetMSBuildSettings(); - var binaryLogger = new MSBuildBinaryLogSettings { - Enabled = isCIBuild - }; - - msbuildSettings.BinaryLogger = binaryLogger; - binaryLogger.FileName = $"{artifactStagingDirectory}/Maui.Controls-{configuration}.binlog"; - MSBuild(MAUI_SLN, msbuildSettings.WithRestore()); - - // // This currently fails on CI will revisit later - // if(isCIBuild) - // { - // MSBuild("./Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj", GetMSBuildSettings().WithTarget("Restore")); - // MSBuild("./Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj", GetMSBuildSettings()); - // } - - // MSBuild(MAUI_SLN, GetMSBuildSettings().WithTarget("Restore")); - // MSBuild("./Xamarin.Forms.DualScreen.sln", GetMSBuildSettings().WithTarget("Restore")); - - // if(isCIBuild) - // { - // foreach(var platformProject in GetFiles("./Xamarin.*.UnitTests/*.csproj").Select(x=> x.FullPath)) - // { - // if(platformProject.Contains("Xamarin.Forms.Xaml.UnitTests")) - // continue; - - // Information("Building: {0}", platformProject); - // MSBuild(platformProject, - // GetMSBuildSettings().WithRestore()); - // } - // } - - // MSBuild(MAUI_SLN, GetMSBuildSettings().WithTarget("Restore")); - // MSBuild("./Xamarin.Forms.DualScreen.sln", GetMSBuildSettings().WithTarget("Restore")); - - // msbuildSettings.BinaryLogger = binaryLogger; - - // var platformProjects = - // GetFiles("./Xamarin.Forms.Platform.*/*.csproj") - // .Union(GetFiles("./Stubs/*/*.csproj")) - // .Union(GetFiles("./Xamarin.Forms.Maps.*/*.csproj")) - // .Union(GetFiles("./Xamarin.Forms.Pages.*/*.csproj")) - // .Union(GetFiles("./Xamarin.Forms.Material.*/*.csproj")) - // .Union(GetFiles("./Xamarin.Forms.Core.Design/*.csproj")) - // .Union(GetFiles("./Xamarin.Forms.Xaml.Design/*.csproj")) - // .Select(x=> x.FullPath).Distinct() - // .ToList(); - - // foreach(var platformProject in platformProjects) - // { - // if(platformProject.Contains("UnitTests")) - // continue; - - // msbuildSettings = GetMSBuildSettings(); - // string projectName = platformProject - // .Replace(' ', '_') - // .Split('/') - // .Last(); - - // binaryLogger.FileName = $"{artifactStagingDirectory}/{projectName}-{configuration}.binlog"; - // msbuildSettings.BinaryLogger = binaryLogger; - - // Information("Building: {0}", platformProject); - // MSBuild(platformProject, - // msbuildSettings); - // } - - // dual screen - - - // XAML Tests are currently having issues compiling in Release Mode - // if(configuration == "Debug") - // { - // msbuildSettings = GetMSBuildSettings(); - // msbuildSettings.BinaryLogger = binaryLogger; - // binaryLogger.FileName = $"{artifactStagingDirectory}/ControlGallery-{configuration}.binlog"; - // MSBuild(CONTROLGALLERY_SLN, msbuildSettings.WithRestore()); - // } - - if(IsRunningOnWindows()) - { - // msbuildSettings = GetMSBuildSettings(); - // msbuildSettings.BinaryLogger = binaryLogger; - // binaryLogger.FileName = $"{artifactStagingDirectory}/dualscreen-{configuration}-csproj.binlog"; - // MSBuild("./Xamarin.Forms.DualScreen/Xamarin.Forms.DualScreen.csproj", - // msbuildSettings - // .WithRestore() - // .WithTarget("rebuild")); - - - // msbuildSettings = GetMSBuildSettings(); - // msbuildSettings.BinaryLogger = binaryLogger; - // binaryLogger.FileName = $"{artifactStagingDirectory}/win-maps-{configuration}-csproj.binlog"; - // MSBuild("./Xamarin.Forms.Maps.UWP/Xamarin.Forms.Maps.UWP.csproj", - // msbuildSettings - // .WithProperty("UwpMinTargetFrameworks", "uap10.0.14393") - // .WithRestore()); - - // msbuildSettings = GetMSBuildSettings(); - // msbuildSettings.BinaryLogger = binaryLogger; - // binaryLogger.FileName = $"{artifactStagingDirectory}/win-{configuration}-csproj.binlog"; - // MSBuild("./src/Compatibility/Core/src/UAP/Compatibility.UAP.csproj", - // msbuildSettings - // .WithRestore() - // .WithTarget("rebuild") - // .WithProperty("DisableEmbeddedXbf", "false") - // .WithProperty("EnableTypeInfoReflection", "false")); - - // msbuildSettings = GetMSBuildSettings(); - // msbuildSettings.BinaryLogger = binaryLogger; - // binaryLogger.FileName = $"{artifactStagingDirectory}/ios-{configuration}-csproj.binlog"; - // MSBuild("./Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj", - // msbuildSettings - // .WithTarget("rebuild")); - - // msbuildSettings = GetMSBuildSettings(); - // msbuildSettings.BinaryLogger = binaryLogger; - // binaryLogger.FileName = $"{artifactStagingDirectory}/macos-{configuration}-csproj.binlog"; - // MSBuild("./Xamarin.Forms.Platform.MacOS/Xamarin.Forms.Platform.MacOS.csproj", - // msbuildSettings - // .WithTarget("rebuild")); - } - - } - catch(Exception) - { - if(IsRunningOnWindows()) - throw; - } -}); - Task("BuildTasks") .Description($"Build {BUILD_TASKS_PROJ}") .Does(() => @@ -898,45 +750,6 @@ Task("Android100") .WithProperty("AndroidTargetFrameworks", "MonoAndroid10.0")); }); - -Task("VS-NET6") - .Does(() => - { - DotNetCoreBuild("./src/DotNet/Dotnet.csproj"); - var ext = IsRunningOnWindows() ? ".exe" : ""; - DotNetCoreBuild("./Microsoft.Maui.BuildTasks-net6.sln", new DotNetCoreBuildSettings { ToolPath = $"./bin/dotnet/dotnet{ext}" }); - StartVisualStudioForDotNet6(); - }); - - -Task("VS-ANDROID") - .Does(() => - { - DotNetCoreBuild("./src/DotNet/Dotnet.csproj"); - var ext = IsRunningOnWindows() ? ".exe" : ""; - DotNetCoreBuild("./Microsoft.Maui.BuildTasks-net6.sln", new DotNetCoreBuildSettings { ToolPath = $"./bin/dotnet/dotnet{ext}" }); - StartVisualStudioForDotNet6("./Microsoft.Maui.Droid.sln"); - }); - - -Task("VS-WINUI") - .IsDependentOn("Clean") - .Does(() => - { - DotNetCoreBuild("./src/DotNet/Dotnet.csproj"); - var ext = IsRunningOnWindows() ? ".exe" : ""; - - StartProcess("powershell", $"./eng/dogfood.ps1 -JustCreateGlobalJSON"); - DotNetCoreBuild("./Microsoft.Maui.BuildTasks-net6.sln", new DotNetCoreBuildSettings { ToolPath = $"./bin/dotnet/dotnet{ext}" }); - - - MSBuild("Microsoft.Maui.WinUI.sln", - GetMSBuildSettings(includePrerelease:true). - WithRestore()); - - StartVisualStudioForDotNet6("./Microsoft.Maui.WinUI.sln"); - }); - Task("VS") .Description("Builds projects necessary so solution compiles on VS") .IsDependentOn("Clean") @@ -1196,9 +1009,7 @@ Task ("cg-ios-deploy") // TASK TARGETS ////////////////////////////////////////////////////////////////////// -Task("Default") - .IsDependentOn("NugetPack") - ; +Task("Default").IsDependentOn("dotnet-pack"); ////////////////////////////////////////////////////////////////////// // EXECUTION @@ -1238,14 +1049,6 @@ void RunTests(string unitTestLibrary, NUnit3Settings settings, ICakeContext ctx) } } -T GetBuildVariable(string key, T defaultValue) -{ - // on MAC all environment variables are upper case regardless of how you specify them in devops - // And then Environment Variable check is case sensitive - T upperCaseReturnValue = Argument(key.ToUpper(), EnvironmentVariable(key.ToUpper(), defaultValue)); - return Argument(key, EnvironmentVariable(key, upperCaseReturnValue)); -} - void StartVisualStudio(string sln = "./Microsoft.Maui.sln") { if(isCIBuild) @@ -1265,22 +1068,6 @@ void StartVisualStudio(string sln = "./Microsoft.Maui.sln") StartProcess("open", new ProcessSettings{ Arguments = sln }); } -void StartVisualStudioForDotNet6(string sln = "./Microsoft.Maui-net6.sln") -{ - if (isCIBuild) - return; - if (!IsRunningOnWindows()) - { - Information("This target is only supported on Windows."); - return; - } - var vsLatest = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = true, }); - if (vsLatest == null) - throw new Exception("Unable to find Visual Studio!"); - var devenv = vsLatest.CombineWithFilePath("./Common7/IDE/devenv.exe"); - StartProcess("powershell", $"./eng/dogfood.ps1 -vs '{devenv}' -sln '{sln}'"); -} - MSBuildSettings GetMSBuildSettings( PlatformTarget? platformTarget = PlatformTarget.MSIL, string buildConfiguration = null, @@ -1489,4 +1276,4 @@ public string ParseDevOpsInputs(string nunitWhere) } return returnValue; -} +} \ No newline at end of file diff --git a/eng/cake/.gitignore b/eng/cake/.gitignore new file mode 100644 index 0000000000..c50f923c7b --- /dev/null +++ b/eng/cake/.gitignore @@ -0,0 +1 @@ +tools/ diff --git a/eng/cake/dotnet.cake b/eng/cake/dotnet.cake new file mode 100644 index 0000000000..19a50e6f1d --- /dev/null +++ b/eng/cake/dotnet.cake @@ -0,0 +1,223 @@ +// Contains .NET 6-related Cake targets + +var ext = IsRunningOnWindows() ? ".exe" : ""; +var dotnetPath = $"./bin/dotnet/dotnet{ext}"; + +Task("dotnet") + .Description("Provisions .NET 6 into bin/dotnet based on eng/Versions.props") + .Does(() => + { + var binlog = $"artifacts/dotnet-{configuration}.binlog"; + var settings = new DotNetCoreBuildSettings + { + MSBuildSettings = new DotNetCoreMSBuildSettings() + .EnableBinaryLogger(binlog) + .SetConfiguration(configuration), + }; + DotNetCoreBuild("./src/DotNet/DotNet.csproj", settings); + }); + +Task("dotnet-pack") + .Description("Build and create .NET 6 NuGet packages") + //.IsDependentOn("dotnet") + // .IsDependentOn("dotnet-buildtasks") + .Does(()=> + { + + var settings = new DotNetCoreToolSettings + { + DiagnosticOutput = true, + ArgumentCustomization = args => args.Append($"./eng/package.ps1 -configuration \"{configuration}\"") + }; + + DotNetCoreTool("pwsh", settings); + + // RunMSBuildWithLocalDotNet("Microsoft.Maui-net6.sln", (settings) => + // { + // if (settings is MSBuildSettings msbuildSettings) + // { + // msbuildSettings + // .WithProperty("Packing", "true") + // .WithProperty("CI", "true") + // .WithTarget("build"); + + // } + // else if( settings is DotNetCoreMSBuildSettings dotnetSettings ) + // { + // dotnetSettings + // .WithProperty("Packing", "true") + // .WithProperty("CI", "true") + // .WithTarget("pack"); + + // } + // }); + + + // if (IsRunningOnWindows()) + // { + // RunMSBuildWithLocalDotNet("Microsoft.Maui-net6.sln", (settings) => + // { + // if (settings is MSBuildSettings msbuildSettings) + // { + // msbuildSettings + // .WithProperty("Packing", "true") + // .WithProperty("CI", "true") + // .WithTarget("pack"); + + // } + // }); + // } + }); + +Task("dotnet-buildtasks") + .IsDependentOn("dotnet") + .Does(() => + { + RunMSBuildWithLocalDotNet("./Microsoft.Maui.BuildTasks-net6.sln"); + }); + +Task("VS-DOGFOOD") + .Description("Provisions .NET 6 and launches an instance of Visual Studio using it.") + .IsDependentOn("dotnet") + .Does(() => + { + StartVisualStudioForDotNet6(null); + }); + +Task("VS-NET6") + .Description("Provisions .NET 6 and launches an instance of Visual Studio using it.") + .IsDependentOn("Clean") + .IsDependentOn("dotnet") + .IsDependentOn("dotnet-buildtasks") + .Does(() => + { + StartVisualStudioForDotNet6(); + }); + +Task("VS-WINUI") + .Description("Provisions .NET 6 and launches an instance of Visual Studio with WinUI projects.") + .IsDependentOn("Clean") + .IsDependentOn("dotnet") + .IsDependentOn("dotnet-buildtasks") + .Does(() => + { + RunMSBuildWithLocalDotNet("./Microsoft.Maui.WinUI.sln"); + StartVisualStudioForDotNet6("./Microsoft.Maui.WinUI.sln"); + }); + +Task("VS-ANDROID") + .Description("Provisions .NET 6 and launches an instance of Visual Studio with Android projects.") + .IsDependentOn("Clean") + .IsDependentOn("dotnet") + .IsDependentOn("dotnet-buildtasks") + .Does(() => + { + DotNetCoreRestore("./Microsoft.Maui-net6.sln", new DotNetCoreRestoreSettings + { + ToolPath = dotnetPath + }); + + StartVisualStudioForDotNet6("./Microsoft.Maui.Droid.sln"); + }); + +string FindMSBuild() +{ + if (IsRunningOnWindows()) + { + var vsInstallation = VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.Component.MSBuild", IncludePrerelease = true }); + if (vsInstallation != null) + { + var path = vsInstallation.CombineWithFilePath(@"MSBuild\Current\Bin\MSBuild.exe"); + if (FileExists(path)) + return path.FullPath; + + path = vsInstallation.CombineWithFilePath(@"MSBuild\15.0\Bin\MSBuild.exe"); + if (FileExists(path)) + return path.FullPath; + } + } + return "msbuild"; +} + +void SetDotNetEnvironmentVariables() +{ + var dotnet = MakeAbsolute(Directory("./bin/dotnet/")).ToString(); + var target = EnvironmentVariableTarget.Process; + Environment.SetEnvironmentVariable("DOTNET_INSTALL_DIR", dotnet, target); + Environment.SetEnvironmentVariable("DOTNET_ROOT", dotnet, target); + Environment.SetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", dotnet, target); + Environment.SetEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0", target); + Environment.SetEnvironmentVariable("MSBuildEnableWorkloadResolver", "true", target); + Environment.SetEnvironmentVariable("PATH", dotnet + System.IO.Path.PathSeparator + EnvironmentVariable("PATH"), target); +} + +void StartVisualStudioForDotNet6(string sln = "./Microsoft.Maui-net6.sln") +{ + if (isCIBuild) + { + Information("This target should not run on CI."); + return; + } + if (!IsRunningOnWindows()) + { + Information("This target is only supported on Windows."); + return; + } + + var vsLatest = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = true, }); + if (vsLatest == null) + throw new Exception("Unable to find Visual Studio!"); + SetDotNetEnvironmentVariables(); + Environment.SetEnvironmentVariable("_ExcludeMauiProjectCapability", "true", EnvironmentVariableTarget.Process); + StartProcess(vsLatest.CombineWithFilePath("./Common7/IDE/devenv.exe"), sln); +} + +// NOTE: this method works as long as the DotNet target has already run +void RunMSBuildWithLocalDotNet(string sln, Action settings = null) +{ + var name = System.IO.Path.GetFileNameWithoutExtension(sln); + var binlog = $"artifacts/{name}-{configuration}.binlog"; + + // If we're not on Windows, just use ./bin/dotnet/dotnet, that's it + if (!IsRunningOnWindows()) + { + var dotnetBuildSettings = new DotNetCoreMSBuildSettings + { + BinaryLogger = new MSBuildBinaryLoggerSettings + { + Enabled = true, + FileName = binlog, + }, + }; + + settings?.Invoke(dotnetBuildSettings); + + DotNetCoreBuild(sln, + new DotNetCoreBuildSettings + { + Configuration = configuration, + ToolPath = dotnetPath, + MSBuildSettings = dotnetBuildSettings, + }); + return; + } + + // Otherwise we need to set env variables and run MSBuild + SetDotNetEnvironmentVariables(); + var msbuildSettings = new MSBuildSettings + { + Configuration = configuration, + BinaryLogger = new MSBuildBinaryLogSettings + { + Enabled = true, + FileName = binlog, + }, + ToolPath = FindMSBuild(), + }; + + settings?.Invoke(msbuildSettings); + + MSBuild(sln, + msbuildSettings + .WithRestore()); +} diff --git a/eng/cake/helpers.cake b/eng/cake/helpers.cake new file mode 100644 index 0000000000..aa74e0e11f --- /dev/null +++ b/eng/cake/helpers.cake @@ -0,0 +1,31 @@ +Task("Clean") + .Description("Deletes all the obj/bin directories") + .Does(() => +{ + List foldersToClean = new List(); + + foreach (var item in new [] {"obj", "bin"}) + { + foreach(string f in System.IO.Directory.GetDirectories(".", item, SearchOption.AllDirectories)) + { + if(f.StartsWith(@".\bin") || f.StartsWith(@".\tools")) + continue; + + // this is here as a safety check + if(!f.StartsWith(@".\src")) + continue; + + CleanDirectories(f); + } + } +}); + + + +T GetBuildVariable(string key, T defaultValue) +{ + // on MAC all environment variables are upper case regardless of how you specify them in devops + // And then Environment Variable check is case sensitive + T upperCaseReturnValue = Argument(key.ToUpper(), EnvironmentVariable(key.ToUpper(), defaultValue)); + return Argument(key, EnvironmentVariable(key, upperCaseReturnValue)); +} \ No newline at end of file diff --git a/eng/dogfood.ps1 b/eng/dogfood.ps1 deleted file mode 100644 index 0d4ce1fbdc..0000000000 --- a/eng/dogfood.ps1 +++ /dev/null @@ -1,119 +0,0 @@ -<# - .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 or the edition (Community, Enterprise, Preview), defaults to: "Enterprise". - - .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 -vs "Preview" - - .EXAMPLE - PS> .\scripts\dogfood.ps1 -sln .\path\to\MySolution.sln -#> - -param( - [string]$vs = "Enterprise", - [string]$sln, - [switch]$modify, - [switch]$JustCreateGlobalJSON -) - -if ($vs.Contains("\") -Or $vs.Contains("/")) { - $realVS = $vs -} else { - $realVS = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\$vs\Common7\IDE\devenv.exe" -} - -$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 Versions.props) -$json = Get-Content $globaljson | ConvertFrom-Json -$json | Add-Member sdk (New-Object -TypeName PSObject) -Force -$json.sdk | Add-Member version $xml.Project.PropertyGroup.MicrosoftDotnetSdkInternalPackageVersion -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 -# $old_MSBuildDisableNodeReuse=$env:MSBuildDisableNodeReuse -$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 - - # # This tells MSBuild not to keep the process around - # $env:MSBuildDisableNodeReuse=1 - - # Put our local dotnet.exe on PATH first so Visual Studio knows which one to use - $env:PATH=($env:DOTNET_ROOT + ";" + $env:PATH) - - if(-Not $JustCreateGlobalJSON) - { - # Launch VS - & "$realVS" "$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:MSBuildDisableNodeReuse=$oldMSBuildDisableNodeReuse - $env:PATH=$oldPATH - } -} - -exit 0 \ No newline at end of file diff --git a/eng/pipelines/common/build-windows.yml b/eng/pipelines/common/build-windows.yml index ffe67b6f27..f297972d28 100644 --- a/eng/pipelines/common/build-windows.yml +++ b/eng/pipelines/common/build-windows.yml @@ -36,7 +36,7 @@ steps: inputs: script: 'nuget install NUnit3TestAdapter' - - script: build.cmd -Target BuildForNuget -ScriptArgs '--BUILD_CONFIGURATION="$(BuildConfiguration)"','--Build_ArtifactStagingDirectory="$(Build.ArtifactStagingDirectory)"' + - script: build.cmd -Target BuildUnitTests -ScriptArgs '--configuration="$(BuildConfiguration)"','--Build_ArtifactStagingDirectory="$(Build.ArtifactStagingDirectory)"' name: winbuild displayName: 'Build Projects For Nuget' diff --git a/eng/pipelines/common/controlgallery-android.yml b/eng/pipelines/common/controlgallery-android.yml index 5d2dde3c54..71227846b0 100644 --- a/eng/pipelines/common/controlgallery-android.yml +++ b/eng/pipelines/common/controlgallery-android.yml @@ -32,14 +32,14 @@ steps: inputs: targetType: 'filePath' filePath: 'build.sh' - arguments: --target cg-android --ANDROID_RENDERERS="$(renderers)" --GoogleMapsAPIKey="$(GoogleMapsAPIKey)" --BUILD_CONFIGURATION=$(BuildConfiguration) + arguments: --target cg-android --ANDROID_RENDERERS="$(renderers)" --GoogleMapsAPIKey="$(GoogleMapsAPIKey)" --configuration=$(BuildConfiguration) - task: Bash@3 displayName: 'Build Android UITests' inputs: targetType: 'filePath' filePath: 'build.sh' - arguments: --target cg-android-build-tests --BUILD_CONFIGURATION=$(BuildConfiguration) + arguments: --target cg-android-build-tests --configuration=$(BuildConfiguration) - task: CopyFiles@2 displayName: 'Copy Android Files for UITest' diff --git a/eng/pipelines/common/controlgallery-ios.yml b/eng/pipelines/common/controlgallery-ios.yml index 125d41b9fc..0f6e2d6a9d 100644 --- a/eng/pipelines/common/controlgallery-ios.yml +++ b/eng/pipelines/common/controlgallery-ios.yml @@ -52,14 +52,14 @@ steps: inputs: targetType: 'filePath' filePath: 'build.sh' - arguments: --target cg-ios --BUILD_CONFIGURATION=$(BuildConfiguration) + arguments: --target cg-ios --configuration=$(BuildConfiguration) - task: Bash@3 displayName: 'Build iOS UITests Tests' inputs: targetType: 'filePath' filePath: 'build.sh' - arguments: --target cg-ios-build-tests --BUILD_CONFIGURATION=$(BuildConfiguration) + arguments: --target cg-ios-build-tests --configuration=$(BuildConfiguration) - task: CopyFiles@2 displayName: 'Copy iOS Files for UITest' diff --git a/eng/pipelines/common/controlgallery-windows.yml b/eng/pipelines/common/controlgallery-windows.yml new file mode 100644 index 0000000000..c7cc08578b --- /dev/null +++ b/eng/pipelines/common/controlgallery-windows.yml @@ -0,0 +1,25 @@ +steps: + - checkout: self + clean: true + + - task: xamops.azdevex.provisionator-task.provisionator@1 + displayName: 'Provisionator' + condition: eq(variables['provisioning'], 'true') + inputs: + provisioning_script: $(provisionator.path) + provisioning_extra_args: $(provisionator.extraArguments) + + - powershell: | + $(System.DefaultWorkingDirectory)/build.ps1 --target provision --TeamProject="$(System.TeamProject)" + displayName: 'Cake Provision' + condition: eq(variables['provisioningCake'], 'true') + + - powershell: | + $(System.DefaultWorkingDirectory)/build.ps1 --target VS-WINUI --TeamProject="$(System.TeamProject)" + displayName: 'Build WinUI Solution' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: ${{ parameters.artifactsName }}' + condition: always() + inputs: + ArtifactName: WINUI diff --git a/eng/pipelines/common/device-tests-steps.yml b/eng/pipelines/common/device-tests-steps.yml index 4abd1f7694..35dbfe2ae1 100644 --- a/eng/pipelines/common/device-tests-steps.yml +++ b/eng/pipelines/common/device-tests-steps.yml @@ -51,7 +51,7 @@ steps: packageType: 'sdk' - pwsh: | - ./build.ps1 --target=BuildTasks --BUILD_CONFIGURATION=Debug --Build_ArtifactStagingDirectory="$(Build.ArtifactStagingDirectory)" + ./build.ps1 --target=BuildTasks --configuration=Debug --Build_ArtifactStagingDirectory="$(Build.ArtifactStagingDirectory)" name: winbuild displayName: 'Build the MSBuild Tasks' diff --git a/eng/pipelines/handlers.yml b/eng/pipelines/handlers.yml index b02200502f..795538439a 100644 --- a/eng/pipelines/handlers.yml +++ b/eng/pipelines/handlers.yml @@ -131,6 +131,27 @@ stages: steps: - template: common/build-windows.yml + # - stage: windows_controlgallery + # displayName: Build Windows ControlGallery + # dependsOn: [] + # jobs: + # - ${{ each BuildCondition in parameters.BuildConfigurations }}: + # - job: win_hosted_${{ BuildCondition }} + # workspace: + # clean: all + # displayName: Build Windows Phase (${{ BuildCondition }}) + # condition: or( + # ${{ parameters.BuildEverything }}, + # ne(variables['Build.Reason'], 'PullRequest'), + # eq('${{ BuildCondition }}', 'Release')) + # timeoutInMinutes: 60 + # pool: + # name: $(vs2019VmPool) + # vmImage: $(vs2019VmImage) + # demands: [ msbuild ] + # steps: + # - template: common/controlgallery-windows.yml + - stage: build_osx displayName: iOS dependsOn: [] @@ -211,9 +232,10 @@ stages: - ${{ if eq(BuildPlatform.name, 'macos') }}: - script: echo '##vso[task.setvariable variable=JI_JAVA_HOME]$(JAVA_HOME_11_X64)' displayName: set JI_JAVA_HOME - - pwsh: ./eng/package.ps1 -configuration Release + - script: dotnet tool restore + displayName: install dotnet tools + - script: dotnet cake --configuration=Release displayName: pack nugets - errorActionPreference: stop - task: CopyFiles@2 displayName: 'Copy SignList.xml Files' inputs: @@ -223,6 +245,13 @@ stages: **/Microsoft.AspNetCore.Components.WebView.Maui.*.nupkg **/Microsoft.AspNetCore.Components.WebView.Maui.*.snupkg **/SignList.xml + TargetFolder: $(build.artifactstagingdirectory) + flattenFolders: true + - task: CopyFiles@2 + displayName: 'Copy Bin Log Files' + condition: always() + inputs: + Contents: | **/*.binlog TargetFolder: $(build.artifactstagingdirectory) flattenFolders: true diff --git a/src/Compatibility/ControlGallery/src/WinUI/BrokenImageSourceHandler.cs b/src/Compatibility/ControlGallery/src/WinUI/BrokenImageSourceHandler.cs index 17d49da71e..88e1008aa1 100644 --- a/src/Compatibility/ControlGallery/src/WinUI/BrokenImageSourceHandler.cs +++ b/src/Compatibility/ControlGallery/src/WinUI/BrokenImageSourceHandler.cs @@ -6,6 +6,7 @@ using WImageSource = Microsoft.UI.Xaml.Media.ImageSource; using Microsoft.Maui.Controls.Compatibility.Platform.UWP; using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI; +using Microsoft.Maui.Controls.Platform; [assembly: ExportRenderer(typeof(_51173Image), typeof(_51173CustomImageRenderer))] namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI diff --git a/src/Compatibility/ControlGallery/src/WinUI/_13109IssueHelper.cs b/src/Compatibility/ControlGallery/src/WinUI/_13109IssueHelper.cs index 6f4499553c..5eb82f2264 100644 --- a/src/Compatibility/ControlGallery/src/WinUI/_13109IssueHelper.cs +++ b/src/Compatibility/ControlGallery/src/WinUI/_13109IssueHelper.cs @@ -4,6 +4,7 @@ using Microsoft.Maui.Controls.Compatibility.Platform.UWP; using Microsoft.Maui.Controls.Compatibility.ControlGallery.Issues; using Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI; using Bitmap = Microsoft.UI.Xaml.Media.ImageSource; +using Microsoft.Maui.Controls.Platform; [assembly: Dependency(typeof(_13109IssueHelper))] namespace Microsoft.Maui.Controls.Compatibility.ControlGallery.WinUI diff --git a/src/Controls/src/Core/Controls.Core-net6.csproj b/src/Controls/src/Core/Controls.Core-net6.csproj index d7927fe6be..ef67c4699a 100644 --- a/src/Controls/src/Core/Controls.Core-net6.csproj +++ b/src/Controls/src/Core/Controls.Core-net6.csproj @@ -1,6 +1,6 @@ - netstandard2.0;$(MauiPlatforms) + netstandard2.0;netstandard2.1;$(MauiPlatforms) Microsoft.Maui.Controls Microsoft.Maui.Controls disable