Skip to content

Commit

Permalink
Merge branch 'main' into fix-somenaming-cells
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarinho committed May 18, 2022
2 parents 09be092 + 4b833b0 commit 21170b1
Show file tree
Hide file tree
Showing 41 changed files with 654 additions and 1,511 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
@@ -1,4 +1,4 @@
blank_issues_enabled: false
blank_issues_enabled: true
contact_links:
- name: .NET MAUI Community Support
url: https://docs.microsoft.com/answers/topics/dotnet-maui.html
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Expand Up @@ -99,6 +99,6 @@
<Import Condition="'$(EnvironmentBuildPropsImported)' != 'True'" Project="$(MSBuildThisFileDirectory)eng\Environment.Build.props" />
<Import Condition="'$(SampleProject)' != 'True' and '$(CI)' == 'true'" Project="$(MSBuildThisFileDirectory)eng\SourceLink.Build.props" />
<ItemGroup Condition="'$(MSBuildVersion)' != '' AND '$(MSBuildVersion)' &lt; '16.7.0' ">
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.2.0" PrivateAssets="all" />
</ItemGroup>
</Project>
1,252 changes: 2 additions & 1,250 deletions build.cake

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion eng/Versions.props
Expand Up @@ -38,7 +38,7 @@
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>3.3.3</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
<MicrosoftMauiGraphicsVersion>6.0.400-preview.1.1367</MicrosoftMauiGraphicsVersion>
<SystemNumericsVectorsVersion>4.5.0</SystemNumericsVectorsVersion>
<_MicrosoftWebWebView2Version>1.0.1210.30</_MicrosoftWebWebView2Version>
<_MicrosoftWebWebView2Version>1.0.1210.39</_MicrosoftWebWebView2Version>
<!-- GLIDE - the android maven artifact in /src/Core/AndroidNative/maui/build.gradle -->
<!-- must be kept in sync with the binding library version to it here: -->
<_XamarinAndroidGlideVersion>4.12.0.8</_XamarinAndroidGlideVersion>
Expand Down
171 changes: 118 additions & 53 deletions eng/cake/dotnet.cake
Expand Up @@ -2,6 +2,11 @@

var ext = IsRunningOnWindows() ? ".exe" : "";
var dotnetPath = $"./bin/dotnet/dotnet{ext}";
string configuration = GetBuildVariable("configuration", GetBuildVariable("BUILD_CONFIGURATION", "DEBUG"));
var localDotnet = GetBuildVariable("workloads", "local") == "local";
var vsVersion = GetBuildVariable("VS", "");
string MSBuildExe = Argument("msbuild", EnvironmentVariable("MSBUILD_EXE", ""));
Exception pendingException = null;

// Tasks for CI

Expand All @@ -15,7 +20,7 @@ Task("dotnet")
DotNetCoreBuild("./src/DotNet/DotNet.csproj", new DotNetCoreBuildSettings
{
MSBuildSettings = new DotNetCoreMSBuildSettings()
.EnableBinaryLogger($"{logDirectory}/dotnet-{configuration}.binlog")
.EnableBinaryLogger($"{GetLogDirectory()}/dotnet-{configuration}.binlog")
.SetConfiguration(configuration),
});
});
Expand All @@ -29,26 +34,37 @@ Task("dotnet-local-workloads")
DotNetCoreBuild("./src/DotNet/DotNet.csproj", new DotNetCoreBuildSettings
{
MSBuildSettings = new DotNetCoreMSBuildSettings()
.EnableBinaryLogger($"{logDirectory}/dotnet-{configuration}.binlog")
.EnableBinaryLogger($"{GetLogDirectory()}/dotnet-{configuration}.binlog")
.SetConfiguration(configuration)
.WithProperty("InstallWorkloadPacks", "false"),
});
DotNetCoreBuild("./src/DotNet/DotNet.csproj", new DotNetCoreBuildSettings
{
MSBuildSettings = new DotNetCoreMSBuildSettings()
.EnableBinaryLogger($"{logDirectory}/dotnet-install-{configuration}.binlog")
.EnableBinaryLogger($"{GetLogDirectory()}/dotnet-install-{configuration}.binlog")
.SetConfiguration(configuration)
.WithTarget("Install"),
ToolPath = dotnetPath,
});
});

Task("dotnet-buildtasks")
.WithCriteria(Argument<string>("sln", null) == null)
.IsDependentOn("dotnet")
.Does(() =>
{
RunMSBuildWithDotNet("./Microsoft.Maui.BuildTasks.slnf");
})
.OnError(exception =>
{
if (IsTarget("VS"))
{
pendingException = exception;
return;
}
throw exception;
});

Task("dotnet-build")
Expand Down Expand Up @@ -80,7 +96,7 @@ Task("dotnet-templates")
var dn = localDotnet ? dotnetPath : "dotnet";
var templatesTest = tempDirectory.Combine("templatesTest");
var templatesTest = GetTempDirectory().Combine("templatesTest");
EnsureDirectoryExists(templatesTest);
CleanDirectories(templatesTest.FullPath);
Expand Down Expand Up @@ -210,6 +226,7 @@ Task("dotnet-test")
});

Task("dotnet-pack-maui")
.WithCriteria(RunPackTarget())
.Does(() =>
{
DotNetCoreTool("pwsh", new DotNetCoreToolSettings
Expand All @@ -220,6 +237,7 @@ Task("dotnet-pack-maui")
});

Task("dotnet-pack-additional")
.WithCriteria(RunPackTarget())
.Does(() =>
{
// Download some additional symbols that need to be archived along with the maui symbols:
Expand All @@ -241,6 +259,7 @@ Task("dotnet-pack-additional")
});

Task("dotnet-pack-library-packs")
.WithCriteria(RunPackTarget())
.Does(() =>
{
var tempDir = $"./artifacts/library-packs-temp";
Expand Down Expand Up @@ -270,6 +289,7 @@ Task("dotnet-pack-library-packs")
});

Task("dotnet-pack")
.WithCriteria(RunPackTarget())
.IsDependentOn("dotnet-pack-maui")
.IsDependentOn("dotnet-pack-additional")
.IsDependentOn("dotnet-pack-library-packs");
Expand All @@ -291,11 +311,11 @@ Task("dotnet-diff")
else
{
// clean all working folders
var diffCacheDir = tempDirectory.Combine("diffCache");
var diffCacheDir = GetTempDirectory().Combine("diffCache");
EnsureDirectoryExists(diffCacheDir);
CleanDirectories(diffCacheDir.FullPath);
EnsureDirectoryExists(diffDirectory);
CleanDirectories(diffDirectory.FullPath);
EnsureDirectoryExists(GetDiffDirectory());
CleanDirectories(GetDiffDirectory().FullPath);
// run the diff
foreach (var nupkg in nupkgs)
Expand All @@ -311,7 +331,7 @@ Task("dotnet-diff")
.Append("--prerelease")
.Append("--group-ids")
.Append("--ignore-unchanged")
.AppendSwitchQuoted("--output", diffDirectory.FullPath)
.AppendSwitchQuoted("--output", GetDiffDirectory().FullPath)
.AppendSwitchQuoted("--cache", diffCacheDir.FullPath)
});
}
Expand All @@ -326,7 +346,7 @@ Task("dotnet-diff")
Information("Unable to clean up diff cache directory.");
}
var diffs = GetFiles($"{diffDirectory}/**/*.md");
var diffs = GetFiles($"{GetDiffDirectory()}/**/*.md");
if (!diffs.Any())
{
Warning($"##vso[task.logissue type=warning]No NuGet diffs were found.");
Expand Down Expand Up @@ -366,48 +386,58 @@ Task("dotnet-diff")
});

// Tasks for Local Development

Task("VS-DOGFOOD")
.Description("Provisions .NET 6 and launches an instance of Visual Studio using it.")
Task("VS")
.Description("Provisions .NET 6, and launches an instance of Visual Studio using it.")
.IsDependentOn("Clean")
.IsDependentOn("dotnet")
.IsDependentOn("dotnet-buildtasks")
.IsDependentOn("dotnet-pack") // Run conditionally
.Does(() =>
{
StartVisualStudioForDotNet6(null);
});
if (pendingException != null)
{
Error($"{pendingException}");
Error("!!!!BUILD TASKS FAILED: !!!!!");
}
StartVisualStudioForDotNet6();
});

// Keeping this for users that are already using this.
Task("VS-NET6")
.Description("Provisions .NET 6 and launches an instance of Visual Studio using it.")
.IsDependentOn("Clean")
.IsDependentOn("dotnet")
.IsDependentOn("dotnet-buildtasks")
.IsDependentOn("VS")
.Does(() =>
{
StartVisualStudioForDotNet6();
Warning("!!!!Please switch to using the `VS` target.!!!!");
});

Task("VS-WINUI")
.Description("Provisions .NET 6 and launches an instance of Visual Studio with WinUI projects.")
.IsDependentOn("VS-NET6");
// .IsDependentOn("dotnet") WINUI currently can't launch application with local dotnet
// .IsDependentOn("dotnet-buildtasks")
bool RunPackTarget()
{
// Is the user running the pack target explicitly?
if (TargetStartsWith("dotnet-pack"))
return true;

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(() =>
// If the default target is running then let the pack target run
if (IsTarget("Default"))
return true;

// Does the user want to run a pack as part of a different target?
if (HasArgument("pack"))
return true;

// If the request is to open a different sln then let's see if pack has ever run
// if it hasn't then lets pack maui so the sln will open
if (Argument<string>("sln", null) != null)
{
DotNetCoreRestore("./Microsoft.Maui.sln", new DotNetCoreRestoreSettings
{
ToolPath = dotnetPath
});
var mauiPacks = MakeAbsolute(Directory("./bin/dotnet/packs/Microsoft.Maui.Sdk")).ToString();
if (!DirectoryExists(mauiPacks))
return true;
}

// VS has trouble building all the references correctly so this makes sure everything is built
// and we're ready to go right when VS launches
RunMSBuildWithDotNet("./src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj");
StartVisualStudioForDotNet6("./Microsoft.Maui.Droid.sln");
});
return false;
}

string FindMSBuild()
{
Expand All @@ -431,6 +461,30 @@ string FindMSBuild()
return "msbuild";
}


Dictionary<string, string> GetDotNetEnvironmentVariables()
{
Dictionary<string, string> envVariables = new Dictionary<string, string>();
var dotnet = MakeAbsolute(Directory("./bin/dotnet/")).ToString();

envVariables.Add("DOTNET_INSTALL_DIR", dotnet);
envVariables.Add("DOTNET_ROOT", dotnet);
envVariables.Add("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", dotnet);
envVariables.Add("DOTNET_MULTILEVEL_LOOKUP", "0");
envVariables.Add("MSBuildEnableWorkloadResolver", "true");

var existingPath = EnvironmentVariable("PATH");
Information(dotnet + ":" + existingPath);
envVariables.Add("PATH", dotnet + ":" + existingPath);

// Get "full" .binlog in Project System Tools
if (HasArgument("debug"))
envVariables.Add("MSBuildDebugEngine", "1");

return envVariables;

}

void SetDotNetEnvironmentVariables()
{
var dotnet = MakeAbsolute(Directory("./bin/dotnet/")).ToString();
Expand All @@ -441,47 +495,57 @@ void SetDotNetEnvironmentVariables()
SetEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0");
SetEnvironmentVariable("MSBuildEnableWorkloadResolver", "true");
SetEnvironmentVariable("PATH", dotnet, prepend: true);

// Get "full" .binlog in Project System Tools
if (HasArgument("debug"))
SetEnvironmentVariable("MSBuildDebugEngine", "1");
}

void StartVisualStudioForDotNet6(string sln = null)
void StartVisualStudioForDotNet6()
{
if (sln == null)
string sln = Argument<string>("sln", null);

bool includePrerelease = true;

if (!String.IsNullOrEmpty(vsVersion))
includePrerelease = (vsVersion == "preview");

if (String.IsNullOrWhiteSpace(sln))
{
if (IsRunningOnWindows())
{
sln = "./Microsoft.Maui.sln";
}
else
{
sln = "./Microsoft.Maui-mac.slnf";
sln = "_omnisharp.sln";
}
}
if (isCIBuild)

if (IsCIBuild())
{
Information("This target should not run on CI.");
Error("This target should not run on CI.");
return;
}

if(localDotnet)
{
SetDotNetEnvironmentVariables();
SetEnvironmentVariable("_ExcludeMauiProjectCapability", "true");
}

if (IsRunningOnWindows())
{
bool includePrerelease = true;

if (!String.IsNullOrEmpty(vsVersion))
includePrerelease = (vsVersion == "preview");

var vsLatest = VSWhereLatest(new VSWhereLatestSettings { IncludePrerelease = includePrerelease, });
if (vsLatest == null)
throw new Exception("Unable to find Visual Studio!");

StartProcess(vsLatest.CombineWithFilePath("./Common7/IDE/devenv.exe"), sln);
}
else
{
StartProcess("open", new ProcessSettings{ Arguments = sln });

StartProcess("open", new ProcessSettings{ Arguments = sln, EnvironmentVariables = GetDotNetEnvironmentVariables() });
}
}

Expand All @@ -501,8 +565,8 @@ void RunMSBuildWithDotNet(
var name = System.IO.Path.GetFileNameWithoutExtension(sln);
var type = useDotNetBuild ? "dotnet" : "msbuild";
var binlog = string.IsNullOrEmpty(targetFramework) ?
$"\"{logDirectory}/{name}-{configuration}-{target}-{type}.binlog\"" :
$"\"{logDirectory}/{name}-{configuration}-{target}-{targetFramework}-{type}.binlog\"";
$"\"{GetLogDirectory()}/{name}-{configuration}-{target}-{type}.binlog\"" :
$"\"{GetLogDirectory()}/{name}-{configuration}-{target}-{targetFramework}-{type}.binlog\"";

if(localDotnet)
SetDotNetEnvironmentVariables();
Expand Down Expand Up @@ -533,6 +597,7 @@ void RunMSBuildWithDotNet(
{
MSBuildSettings = msbuildSettings,
};

dotnetBuildSettings.ArgumentCustomization = args =>
{
if (!restore)
Expand Down Expand Up @@ -588,7 +653,7 @@ void RunMSBuildWithDotNet(
void RunTestWithLocalDotNet(string csproj)
{
var name = System.IO.Path.GetFileNameWithoutExtension(csproj);
var binlog = $"{logDirectory}/{name}-{configuration}.binlog";
var binlog = $"{GetLogDirectory()}/{name}-{configuration}.binlog";
var results = $"{name}-{configuration}.trx";

if(localDotnet)
Expand All @@ -601,7 +666,7 @@ void RunTestWithLocalDotNet(string csproj)
ToolPath = dotnetPath,
NoBuild = true,
Logger = $"trx;LogFileName={results}",
ResultsDirectory = testResultsDirectory,
ResultsDirectory = GetTestResultsDirectory(),
ArgumentCustomization = args => args.Append($"-bl:{binlog}")
});
}

0 comments on commit 21170b1

Please sign in to comment.