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