This commit is contained in:
Rui Marinho 2022-03-23 17:41:54 +00:00
Родитель bc66d1a4b1
Коммит a3e8d7e1d5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 87D2837A9AEED71E
14 изменённых файлов: 589 добавлений и 79 удалений

Просмотреть файл

@ -1,5 +1,20 @@
<Project>
<Import Project="eng\Versions.props" />
<PropertyGroup>
<_MauiDotNetVersion Condition="'$(_MauiDotNetVersion)' == ''">6.0</_MauiDotNetVersion>
<_MauiDotNetTfm Condition="'$(_MauiDotNetTfm)' == ''">net$(_MauiDotNetVersion)</_MauiDotNetTfm>
<_MauiTargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</_MauiTargetPlatformIdentifier>
<_MauiNoTargetPlatform Condition="'$(_MauiTargetPlatformIdentifier)' == ''">True</_MauiNoTargetPlatform>
<_MauiTargetPlatformIsAndroid Condition="'$(_MauiTargetPlatformIdentifier)' == 'android'">True</_MauiTargetPlatformIsAndroid>
<_MauiTargetPlatformIsiOS Condition="'$(_MauiTargetPlatformIdentifier)' == 'ios'">True</_MauiTargetPlatformIsiOS>
<_MauiTargetPlatformIsMacCatalyst Condition="'$(_MauiTargetPlatformIdentifier)' == 'maccatalyst'">True</_MauiTargetPlatformIsMacCatalyst>
<_MauiTargetPlatformIsmacOS Condition="'$(_MauiTargetPlatformIdentifier)' == 'macos'">True</_MauiTargetPlatformIsmacOS>
<_MauiTargetPlatformIstvOS Condition="'$(_MauiTargetPlatformIdentifier)' == 'tvos'">True</_MauiTargetPlatformIstvOS>
<_MauiTargetPlatformIsWindows Condition="$(_MauiTargetPlatformIdentifier.Contains('windows')) == 'True'">True</_MauiTargetPlatformIsWindows>
<IncludeWindowsTargetFrameworks Condition="($([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full') or ('$(Packing)' == 'true')">true</IncludeWindowsTargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
@ -8,17 +23,17 @@
<ProduceReferenceAssembly Condition="'$(UsingMicrosoftNETSdk)' == 'True' AND '$(Configuration)' == 'Debug'">True</ProduceReferenceAssembly>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
</PropertyGroup>
<PropertyGroup>
<MauiRootDirectory>$(MSBuildThisFileDirectory)</MauiRootDirectory>
<DotNetOutputPath>$(MSBuildThisFileDirectory)bin/</DotNetOutputPath>
<DotNetTempDirectory>$(DotNetOutputPath)temp/</DotNetTempDirectory>
<DotNetDirectory Condition="'$(DotNetDirectory)' == ''">$(DotNetOutputPath)dotnet/</DotNetDirectory>
<DotNetDirectoryWithSlash>$([MSBuild]::EnsureTrailingSlash('$(DotNetDirectory)'))</DotNetDirectoryWithSlash>
<DotNetToolPath>$(DotNetDirectoryWithSlash)dotnet</DotNetToolPath>
<DotNetPacksDirectory>$(DotNetDirectoryWithSlash)packs/</DotNetPacksDirectory>
<DotNetLibraryPacksDirectory>$(DotNetDirectoryWithSlash)library-packs/</DotNetLibraryPacksDirectory>
<DotNetSdkManifestsDirectory>$(DotNetDirectoryWithSlash)sdk-manifests/$(DotNetVersionBand)/</DotNetSdkManifestsDirectory>
<DotNetTemplatePacksDirectory>$(DotNetDirectoryWithSlash)template-packs/</DotNetTemplatePacksDirectory>
<DotNetDirectory>$(DotNetOutputPath)dotnet/</DotNetDirectory>
<DotNetToolPath>$(DotNetDirectory)dotnet</DotNetToolPath>
<DotNetPacksDirectory>$(DotNetDirectory)packs/</DotNetPacksDirectory>
<DotNetLibraryPacksDirectory>$(DotNetDirectory)library-packs/</DotNetLibraryPacksDirectory>
<DotNetSdkManifestsDirectory>$(DotNetDirectory)sdk-manifests/$(DotNetVersionBand)/</DotNetSdkManifestsDirectory>
<DotNetTemplatePacksDirectory>$(DotNetDirectory)template-packs/</DotNetTemplatePacksDirectory>
</PropertyGroup>
<PropertyGroup>
<GitDefaultBranch>main</GitDefaultBranch>

Просмотреть файл

@ -3,18 +3,28 @@
<packageSources>
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-emsdk -->
<!-- End: Package sources from dotnet-emsdk -->
<!-- Begin: Package sources from dotnet-runtime -->
<add key="darc-pub-dotnet-runtime-4050c12" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-4050c126/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-runtime -->
<!-- Begin: Package sources from dotnet-windowsdesktop -->
<!-- End: Package sources from dotnet-windowsdesktop -->
<!-- Begin: Package sources from dotnet-emsdk -->
<add key="darc-pub-dotnet-emsdk-572aeed" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-572aeedc/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-emsdk -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
<!-- <add key="local" value="artifacts" /> -->
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" protocolVersion="3" />
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" protocolVersion="3" />
<add key="dotnet6" value="https://aka.ms/dotnet6/nuget/index.json" />
<add key="skiasharp" value="https://aka.ms/skiasharp-eap/index.json" />
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="dotnet7" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json" />
<add key="skiasharp" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/SkiaSharp/nuget/v3/index.json" />
<add key="wasdk-internal" value="https://pkgs.dev.azure.com/microsoft/ProjectReunion/_packaging/Project.Reunion.nuget.internal/nuget/v3/index.json" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
<disabledPackageSources>
<add key="wasdk-internal" value="true" />
</disabledPackageSources>
<disabledPackageSources />
</configuration>

Просмотреть файл

@ -106,6 +106,13 @@ stages:
- pwsh: dotnet tool restore
displayName: install dotnet tools
- pwsh: ./build.ps1 --target=dotnet --configuration="${{ BuildConfiguration }}" --verbosity=diagnostic
displayName: 'Install .NET'
retryCountOnTaskFailure: 3
env:
DOTNET_TOKEN: $(dotnetbuilds-internal-container-read-token)
PRIVATE_BUILD: $(PrivateBuild)
- pwsh: |
[xml] $fileXml = Get-Content "eng\Versions.props"
$DotNetVersion = $fileXml.SelectSingleNode("Project/PropertyGroup/MicrosoftDotnetSdkInternalPackageVersion").InnerText

Просмотреть файл

@ -23,6 +23,7 @@ PowerShell:
// #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
@ -36,13 +37,24 @@ PowerShell:
string agentName = EnvironmentVariable("AGENT_NAME", "");
bool isCIBuild = !String.IsNullOrWhiteSpace(agentName);
string artifactStagingDirectory = EnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY", ".");
string workingDirectory = EnvironmentVariable("SYSTEM_DEFAULTWORKINGDIRECTORY", ".");
string envProgramFiles = EnvironmentVariable("ProgramFiles(x86)");
var configuration = GetBuildVariable("BUILD_CONFIGURATION", GetBuildVariable("configuration", "DEBUG"));
var msbuildPath = GetBuildVariable("msbuild", $"{envProgramFiles}\\Microsoft Visual Studio\\2019\\Enterprise\\MSBuild\\Current\\Bin\\MSBuild.exe");
bool isHostedAgent = agentName.StartsWith("Azure Pipelines") || agentName.StartsWith("Hosted Agent");
var localDotnet = GetBuildVariable("workloads", (target == "VS-WINUI") ? "global" : "local") == "local";
var vsVersion = GetBuildVariable("VS", "");
DirectoryPath artifactStagingDirectory = MakeAbsolute(Directory(EnvironmentVariable("BUILD_ARTIFACTSTAGINGDIRECTORY", "artifacts")));
DirectoryPath logDirectory = MakeAbsolute(Directory(EnvironmentVariable("LogDirectory", $"{artifactStagingDirectory}/logs")));
DirectoryPath testResultsDirectory = MakeAbsolute(Directory(EnvironmentVariable("TestResultsDirectory", $"{artifactStagingDirectory}/test-results")));
DirectoryPath diffDirectory = MakeAbsolute(Directory(EnvironmentVariable("ApiDiffDirectory", $"{artifactStagingDirectory}/api-diff")));
DirectoryPath tempDirectory = MakeAbsolute(Directory(EnvironmentVariable("AGENT_TEMPDIRECTORY", EnvironmentVariable("TEMP", EnvironmentVariable("TMPDIR", "../maui-temp")) + "/" + Guid.NewGuid())));
string MSBuildExe = Argument("msbuild", EnvironmentVariable("MSBUILD_EXE", ""));
string MSBuildArgumentsENV = EnvironmentVariable("MSBuildArguments", "");
string MSBuildArgumentsARGS = Argument("MSBuildArguments", "");
string MSBuildArguments;
var target = Argument("target", "Default");
if(String.IsNullOrWhiteSpace(target))
@ -52,18 +64,10 @@ if(String.IsNullOrWhiteSpace(target))
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default").IsDependentOn("dotnet-pack");
Task("Default").IsDependentOn("dotnet");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);
T GetBuildVariable<T>(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));
}
RunTarget(target);

6
build.cmd Normal file
Просмотреть файл

@ -0,0 +1,6 @@
@ECHO OFF
SETLOCAL
PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; try { & '%~dp0build.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }"
SET exit_code=%ERRORLEVEL%
ECHO build.cmd completed
EXIT /b %exit_code%

20
build.ps1 Normal file
Просмотреть файл

@ -0,0 +1,20 @@
# script inspired by https://andrewlock.net/simplifying-the-cake-global-tool-bootstrapper-scripts-in-netcore3-with-local-tools/
[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Target,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
# Restore Cake tool
& dotnet tool restore
# Build Cake arguments
$cakeArguments = @("$Script");
if ($Target) { $cakeArguments += "--target=$Target" }
$cakeArguments += $ScriptArgs
& dotnet tool run dotnet-cake -- $cakeArguments
exit $LASTEXITCODE

30
build.sh Normal file
Просмотреть файл

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# script inspired by https://andrewlock.net/simplifying-the-cake-global-tool-bootstrapper-scripts-in-netcore3-with-local-tools/
# Define default arguments.
SCRIPT="build.cake"
CAKE_ARGUMENTS=()
# Parse arguments.
for i in "$@"; do
case $1 in
-s|--script) SCRIPT="$2"; shift ;;
--) shift; CAKE_ARGUMENTS+=("$@"); break ;;
*) CAKE_ARGUMENTS+=("$1") ;;
esac
shift
done
# Restore Cake tool
dotnet tool restore
if [ $? -ne 0 ]; then
echo "An error occured while installing Cake."
exit 1
fi
echo "${CAKE_ARGUMENTS[@]}"
# Start Cake
dotnet tool run dotnet-cake "$SCRIPT" "${CAKE_ARGUMENTS[@]}"

Просмотреть файл

@ -1,18 +1,14 @@
<Project Sdk="Microsoft.Build.NoTargets">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<DotNetVersionBandMonoToolchain Condition="'$(DotNetVersionBandMonoToolchain)' == ''">$(DotNetVersionBand)</DotNetVersionBandMonoToolchain>
<DotNetVersionBandEmscripten Condition="'$(DotNetVersionBandEmscripten)' == ''">$(DotNetVersionBand)</DotNetVersionBandEmscripten>
<DotNetVersionBandAndroid Condition="'$(DotNetVersionBandAndroid)' == ''">$(DotNetVersionBand)</DotNetVersionBandAndroid>
<DotNetVersionBandApple Condition="'$(DotNetVersionBandApple)' == ''">$(DotNetVersionBand)</DotNetVersionBandApple>
</PropertyGroup>
<ItemGroup>
<PackageDownload Include="Microsoft.NET.Workload.Mono.ToolChain.Manifest-$(DotNetVersionBandMonoToolchain)" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.Emscripten.Manifest-$(DotNetVersionBandEmscripten)" Version="[$(MicrosoftNETWorkloadEmscriptenPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.Android.Manifest-$(DotNetVersionBandAndroid)" Version="[$(MicrosoftAndroidSdkWindowsPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.MacCatalyst.Manifest-$(DotNetVersionBandApple)" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.iOS.Manifest-$(DotNetVersionBandApple)" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.tvOS.Manifest-$(DotNetVersionBandApple)" Version="[$(MicrosofttvOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.macOS.Manifest-$(DotNetVersionBandApple)" Version="[$(MicrosoftmacOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.Mono.ToolChain.Manifest-$(DotNetMonoManifestVersionBand)" Version="[$(MicrosoftNETCoreAppRefPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Workload.Emscripten.Manifest-$(DotNetEmscriptenManifestVersionBand)" Version="[$(MicrosoftNETWorkloadEmscriptenPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.Android.Manifest-$(DotNetAndroidManifestVersionBand)" Version="[$(MicrosoftAndroidSdkWindowsPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.MacCatalyst.Manifest-$(DotNetMaciOSManifestVersionBand)" Version="[$(MicrosoftMacCatalystSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.iOS.Manifest-$(DotNetMaciOSManifestVersionBand)" Version="[$(MicrosoftiOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.tvOS.Manifest-$(DotNetMaciOSManifestVersionBand)" Version="[$(MicrosofttvOSSdkPackageVersion)]" />
<PackageDownload Include="Microsoft.NET.Sdk.macOS.Manifest-$(DotNetMaciOSManifestVersionBand)" Version="[$(MicrosoftmacOSSdkPackageVersion)]" />
</ItemGroup>
</Project>

Просмотреть файл

@ -2,19 +2,26 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<InstallWorkloadPacks Condition=" '$(InstallWorkloadPacks)' == '' ">true</InstallWorkloadPacks>
<InternalAzureFeed>https://dotnetbuilds.blob.core.windows.net/internal</InternalAzureFeed>
<DotNetFeedUrl>https://dotnetbuilds.blob.core.windows.net/public</DotNetFeedUrl>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('windows'))">
<DotNetInstallScriptUrl>https://dot.net/v1/dotnet-install.ps1</DotNetInstallScriptUrl>
<DotNetInstallScriptName>dotnet-install.ps1</DotNetInstallScriptName>
<DotNetInstallScriptPath>$(DotNetOutputPath)$(DotNetInstallScriptName)</DotNetInstallScriptPath>
<DotNetInstallCommand>&amp; '$(DotNetInstallScriptPath)' -Version $(MicrosoftDotnetSdkInternalPackageVersion) -InstallDir '$(DotNetDirectory)' -Verbose</DotNetInstallCommand>
<DotNetInstallCommand Condition=" '$(PRIVATE_BUILD)' == 'false' ">$(DotNetInstallCommand) -AzureFeed $(DotNetFeedUrl)</DotNetInstallCommand>
<DotNetInstallCommand Condition=" '$(PRIVATE_BUILD)' == 'true' ">$(DotNetInstallCommand) -AzureFeed $(InternalAzureFeed) -FeedCredential $env:DOTNET_TOKEN</DotNetInstallCommand>
<DotNetInstallCommand>powershell -ExecutionPolicy ByPass -NoProfile -Command &quot;$(DotNetInstallCommand)&quot;</DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('osx'))">
<DotNetInstallScriptUrl>https://dot.net/v1/dotnet-install.sh</DotNetInstallScriptUrl>
<DotNetInstallScriptName>dotnet-install.sh</DotNetInstallScriptName>
<DotNetInstallScriptPath>$(DotNetOutputPath)$(DotNetInstallScriptName)</DotNetInstallScriptPath>
<DotNetInstallCommand>sh '$(DotNetInstallScriptPath)' --version $(MicrosoftDotnetSdkInternalPackageVersion) --install-dir '$(DotNetDirectory)' --verbose</DotNetInstallCommand>
<DotNetInstallCommand>bash '$(DotNetInstallScriptPath)' --version $(MicrosoftDotnetSdkInternalPackageVersion) --install-dir '$(DotNetDirectory)' --verbose</DotNetInstallCommand>
<DotNetInstallCommand Condition=" '$(PRIVATE_BUILD)' == 'false' ">$(DotNetInstallCommand) --azure-feed $(DotNetFeedUrl)</DotNetInstallCommand>
<DotNetInstallCommand Condition=" '$(PRIVATE_BUILD)' == 'true' ">$(DotNetInstallCommand) --azure-feed $(InternalAzureFeed) --feed-credential $DOTNET_TOKEN</DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup>
@ -26,28 +33,63 @@
</_ProvisionDependsOn>
</PropertyGroup>
<Target Name="_ReadAllNuGetSources">
<XmlPeek XmlInputPath="../../NuGet.config" Query="configuration/packageSources/add/@value">
<Output TaskParameter="Result" ItemName="_AllNuGetSources" />
</XmlPeek>
</Target>
<!-- Build target provisions ./bin/dotnet/ -->
<Target Name="_Provision" BeforeTargets="Build" DependsOnTargets="$(_ProvisionDependsOn)" />
<!--
Install target takes artifacts/*.nupkg and installs them to the current 'dotnet'.
Running this with ./bin/dotnet/dotnet will work without elevation.
For a system install, you will need to run this in an admin command-prompt on Windows, or use 'sudo' on Mac.
-->
<Target Name="Install" DependsOnTargets="SetVersions">
<Error
Condition=" '$(MSBuildRuntimeType)' != 'Core' "
Text="You should only run this target with 'dotnet build'."
/>
<PropertyGroup>
<_InstallTempDirectory>$(DotNetTempDirectory)install/</_InstallTempDirectory>
</PropertyGroup>
<!-- Setup Microsoft.NET.Sdk.Maui/WorkloadManifest.* -->
<ItemGroup>
<_PackagesToUnzip Include="$(PackageOutputPath)/Microsoft.NET.Sdk.Maui.Manifest-$(DotNetMauiManifestVersionBand).*.nupkg" />
</ItemGroup>
<Unzip
SourceFiles="@(_PackagesToUnzip)"
DestinationFolder="$(_InstallTempDirectory)"
/>
<ItemGroup>
<_WorkloadFiles Include="$(_InstallTempDirectory)data/WorkloadManifest.*" />
</ItemGroup>
<CopyWorkloadFiles
Name="microsoft.net.sdk.maui"
Files="@(_WorkloadFiles)"
WorkloadDirectory="$(MSBuildExtensionsPath)../../sdk-manifests/$(DotNetVersionBand)"
/>
<RemoveDir Directories="$(_InstallTempDirectory)" />
<!-- Run 'dotnet workload install' for the current running 'dotnet' install -->
<ItemGroup>
<_WorkloadSource Include="$(PackageOutputPath)" />
</ItemGroup>
<Copy SourceFiles="$(MauiRootDirectory)NuGet.config" DestinationFolder="$(DotNetTempDirectory)" />
<Exec Command="dotnet nuget add source &quot;$(PackageOutputPath)&quot; --name artifacts --configfile &quot;$(DotNetTempDirectory)NuGet.config&quot;" />
<Exec Command="&quot;$(MSBuildExtensionsPath)../../dotnet&quot; workload install maui --skip-manifest-update --verbosity diag --temp-dir &quot;$(DotNetTempDirectory)&quot; --configfile &quot;$(DotNetTempDirectory)NuGet.config&quot;" WorkingDirectory="$(MauiRootDirectory)" />
</Target>
<PropertyGroup>
<!-- These files should invalidate ./bin/dotnet completely -->
<_Inputs>
$(MSBuildThisFile);
../../eng/Versions.props;
../../NuGet.config;
</_Inputs>
</PropertyGroup>
<Target Name="_DownloadDotNetInstallScript"
Inputs="$(_Inputs)"
Outputs="$(DotNetInstallScriptPath)"
Condition="'$(InstallDotNet)' != 'false'">
Outputs="$(DotNetInstallScriptPath)">
<DownloadFile
SourceUrl="$(DotNetInstallScriptUrl)"
DestinationFolder="$(DotNetOutputPath)"
@ -57,8 +99,7 @@
<Target Name="_InstallDotNet"
Inputs="$(_Inputs)"
Outputs="$(DotNetDirectory).stamp"
Condition="'$(InstallDotNet)' != 'false'">
Outputs="$(DotNetDirectory).stamp">
<RemoveDir Directories="$(DotNetDirectory)" />
<Exec Command="$(DotNetInstallCommand)" />
<Touch Files="$(DotNetDirectory).stamp" AlwaysCreate="true" />
@ -108,11 +149,11 @@
</Target>
<Target Name="_InstallWorkloadPacks"
Condition=" '$(InstallWorkloadPacks)' == 'true' "
Inputs="$(_Inputs)"
Outputs="$(DotNetPacksDirectory).stamp"
DependsOnTargets="_ReadAllNuGetSources">
Outputs="$(DotNetPacksDirectory).stamp">
<Exec
Command="&quot;$(DotNetToolPath)&quot; workload install %(_WorkloadIds.Identity) --skip-manifest-update --verbosity diag --temp-dir &quot;$(DotNetTempDirectory)&quot; @(_AllNuGetSources->'--source &quot;%(Identity)&quot;', ' ')"
Command="&quot;$(DotNetToolPath)&quot; workload install %(_WorkloadIds.Identity) --skip-manifest-update --verbosity diag --temp-dir &quot;$(DotNetTempDirectory)&quot; --configfile &quot;$(MauiRootDirectory)NuGet.config&quot;"
WorkingDirectory="$(MauiRootDirectory)"
/>
<Touch Files="$(DotNetPacksDirectory).stamp" AlwaysCreate="true" />

Просмотреть файл

@ -2,13 +2,13 @@
<ProductDependencies>
<Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.300-preview.22128.2" CoherentParentDependency="Microsoft.Android.Sdk.Windows">
<Uri>https://github.com/dotnet/installer</Uri>
<Sha>2ea9c6a34e055586b6435d7dca837dd01def4f2a</Sha>
<Sha>e45c7d15e572204e3c60e60d2bd529707ddebab9</Sha>
</Dependency>
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.3" CoherentParentDependency="Microsoft.Android.Sdk.Windows">
<Dependency Name="Microsoft.NETCore.App.Ref" Version="6.0.4" CoherentParentDependency="Microsoft.Android.Sdk.Windows">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>3ba4b3f4eb0b5e25d3901090f921c88055cac1b0</Sha>
<Sha>4050c126c96204c3c4cdd9f3ba715a0779201719</Sha>
</Dependency>
<Dependency Name="Microsoft.Android.Sdk.Windows" Version="31.0.200-preview.14.106">
<Dependency Name="Microsoft.Android.Sdk.Windows" Version="31.0.300-rc.1.2">
<Uri>https://github.com/xamarin/xamarin-android</Uri>
<Sha>c71dfe6705d8f2edd8c2c7d75a46ed4797d84982</Sha>
</Dependency>
@ -28,9 +28,9 @@
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>28b9d24b07b4671aa3188f03f8d23c50b28b16c8</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.Manifest-6.0.100" Version="6.0.2" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Dependency Name="Microsoft.NET.Workload.Emscripten.Manifest-6.0.300" Version="6.0.4" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>ee0a97a0009c0e048789126253fea7994db676ac</Sha>
<Sha>572aeedcfa16bdb619fafcecf5924e5c6b65b07b</Sha>
</Dependency>
</ProductDependencies>
</Dependencies>

Просмотреть файл

@ -4,25 +4,25 @@
<!-- dotnet/installer -->
<MicrosoftDotnetSdkInternalPackageVersion>6.0.300-preview.22128.2</MicrosoftDotnetSdkInternalPackageVersion>
<!-- dotnet/runtime -->
<MicrosoftNETCoreAppRefPackageVersion>6.0.3</MicrosoftNETCoreAppRefPackageVersion>
<MicrosoftNETCoreAppRefPackageVersion>6.0.4</MicrosoftNETCoreAppRefPackageVersion>
<!-- dotnet/emsdk -->
<MicrosoftNETWorkloadEmscriptenPackageVersion>6.0.2</MicrosoftNETWorkloadEmscriptenPackageVersion>
<MicrosoftNETWorkloadEmscriptenManifest60300PackageVersion>6.0.4</MicrosoftNETWorkloadEmscriptenManifest60300PackageVersion>
<MicrosoftNETWorkloadEmscriptenPackageVersion>$(MicrosoftNETWorkloadEmscriptenManifest60300PackageVersion)</MicrosoftNETWorkloadEmscriptenPackageVersion>
<!-- xamarin/xamarin-android -->
<MicrosoftAndroidSdkWindowsPackageVersion>31.0.200-preview.14.106</MicrosoftAndroidSdkWindowsPackageVersion>
<MicrosoftAndroidSdkWindowsPackageVersion>31.0.300-rc.1.2</MicrosoftAndroidSdkWindowsPackageVersion>
<!-- xamarin/xamarin-macios -->
<MicrosoftiOSSdkPackageVersion>15.4.100-rc.1.64</MicrosoftiOSSdkPackageVersion>
<MicrosoftMacCatalystSdkPackageVersion>15.4.100-rc.1.64</MicrosoftMacCatalystSdkPackageVersion>
<MicrosoftmacOSSdkPackageVersion>12.3.100-rc.1.64</MicrosoftmacOSSdkPackageVersion>
<MicrosofttvOSSdkPackageVersion>15.4.100-rc.1.64</MicrosofttvOSSdkPackageVersion>
<!-- emsdk -->
<MicrosoftNETWorkloadEmscriptenManifest60100PackageVersion>6.0.2</MicrosoftNETWorkloadEmscriptenManifest60100PackageVersion>
<DotNetVersionBandMonoToolchain>6.0.200</DotNetVersionBandMonoToolchain>
<DotNetVersionBandEmscripten>6.0.200</DotNetVersionBandEmscripten>
<DotNetVersionBandAndroid>6.0.200</DotNetVersionBandAndroid>
<DotNetVersionBandApple>6.0.200</DotNetVersionBandApple>
</PropertyGroup>
<PropertyGroup>
<!-- NOTE: temporarily hardcode 6.0.100, until we have new branding on dotnet/runtime packs -->
<DotNetVersionBand Condition=" '$(DotNetVersionBand)' == '' ">6.0.300</DotNetVersionBand>
<!-- NOTE: temporarily hardcode these to 6.0.200 -->
<DotNetMauiManifestVersionBand>$(DotNetVersionBand)</DotNetMauiManifestVersionBand>
<DotNetMonoManifestVersionBand>$(DotNetVersionBand)</DotNetMonoManifestVersionBand>
<DotNetEmscriptenManifestVersionBand>$(DotNetVersionBand)</DotNetEmscriptenManifestVersionBand>
<DotNetAndroidManifestVersionBand>$(DotNetVersionBand)</DotNetAndroidManifestVersionBand>
<DotNetMaciOSManifestVersionBand>$(DotNetVersionBand)</DotNetMaciOSManifestVersionBand>
</PropertyGroup>
</Project>

1
eng/cake/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
tools/

Просмотреть файл

@ -3,31 +3,324 @@
var ext = IsRunningOnWindows() ? ".exe" : "";
var dotnetPath = $"./bin/dotnet/dotnet{ext}";
// Tasks for CI
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
if (!localDotnet)
return;
DotNetCoreBuild("./build/DotNet/DotNet.csproj", new DotNetCoreBuildSettings
{
MSBuildSettings = new DotNetCoreMSBuildSettings()
.EnableBinaryLogger(binlog)
.EnableBinaryLogger($"{logDirectory}/dotnet-{configuration}.binlog")
.SetConfiguration(configuration),
};
DotNetCoreBuild("./build/DotNet/DotNet.csproj", settings);
});
});
Task("dotnet-pack")
.Description("Build and create .NET 6 NuGet packages")
.Does(()=>
Task("dotnet-local-workloads")
.Does(() =>
{
var settings = new DotNetCoreToolSettings
if (!localDotnet)
return;
DotNetCoreBuild("./build/DotNet/DotNet.csproj", new DotNetCoreBuildSettings
{
DiagnosticOutput = true,
ArgumentCustomization = args => args.Append($"./eng/package.ps1 -configuration \"{configuration}\"")
MSBuildSettings = new DotNetCoreMSBuildSettings()
.EnableBinaryLogger($"{logDirectory}/dotnet-{configuration}.binlog")
.SetConfiguration(configuration)
.WithProperty("InstallWorkloadPacks", "false"),
});
DotNetCoreBuild("./build/DotNet/DotNet.csproj", new DotNetCoreBuildSettings
{
MSBuildSettings = new DotNetCoreMSBuildSettings()
.EnableBinaryLogger($"{logDirectory}/dotnet-install-{configuration}.binlog")
.SetConfiguration(configuration)
.WithTarget("Install"),
ToolPath = dotnetPath,
});
});
Task("dotnet-diff")
.Does(() =>
{
var nupkgs = GetFiles($"./artifacts/**/*.nupkg");
if (!nupkgs.Any())
{
Warning($"##vso[task.logissue type=warning]No NuGet packages were found.");
}
else
{
// clean all working folders
var diffCacheDir = tempDirectory.Combine("diffCache");
EnsureDirectoryExists(diffCacheDir);
CleanDirectories(diffCacheDir.FullPath);
EnsureDirectoryExists(diffDirectory);
CleanDirectories(diffDirectory.FullPath);
// run the diff
foreach (var nupkg in nupkgs)
{
DotNetCoreTool("api-tools", new DotNetCoreToolSettings
{
DiagnosticOutput = true,
ArgumentCustomization = builder => builder
.Append("nuget-diff")
.AppendQuoted(nupkg.FullPath)
.Append("--latest")
// .Append("--verbose")
.Append("--prerelease")
.Append("--group-ids")
.Append("--ignore-unchanged")
.AppendSwitchQuoted("--output", diffDirectory.FullPath)
.AppendSwitchQuoted("--cache", diffCacheDir.FullPath)
});
}
// clean working folders
try
{
CleanDirectories(diffCacheDir.FullPath);
}
catch
{
Information("Unable to clean up diff cache directory.");
}
var diffs = GetFiles($"{diffDirectory}/**/*.md");
if (!diffs.Any())
{
Warning($"##vso[task.logissue type=warning]No NuGet diffs were found.");
}
else
{
// clean working folders
var temp = diffCacheDir.Combine("md-files");
EnsureDirectoryExists(diffCacheDir);
CleanDirectories(diffCacheDir.FullPath);
// copy and rename files for UI
foreach (var diff in diffs)
{
var segments = diff.Segments.Reverse().ToArray();
var nugetId = segments[2];
var platform = segments[1];
var assembly = ((FilePath)segments[0]).GetFilenameWithoutExtension().GetFilenameWithoutExtension();
var breaking = segments[0].EndsWith(".breaking.md");
// using non-breaking spaces
var newName = breaking ? "[BREAKING] " : "";
newName += $"{nugetId} {assembly} ({platform}).md";
var newPath = diffCacheDir.CombineWithFilePath(newName);
CopyFile(diff, newPath);
}
// push changes to UI
var temps = GetFiles($"{diffCacheDir}/**/*.md");
foreach (var t in temps.OrderBy(x => x.FullPath))
{
Information($"##vso[task.uploadsummary]{t}");
}
}
}
});
string FindMSBuild()
{
if (!string.IsNullOrWhiteSpace(MSBuildExe))
return MSBuildExe;
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();
SetEnvironmentVariable("DOTNET_INSTALL_DIR", dotnet);
SetEnvironmentVariable("DOTNET_ROOT", dotnet);
SetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", dotnet);
SetEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0");
SetEnvironmentVariable("MSBuildEnableWorkloadResolver", "true");
SetEnvironmentVariable("PATH", dotnet, prepend: true);
}
void StartVisualStudioForDotNet6(string sln = null)
{
if (sln == null)
{
if (IsRunningOnWindows())
{
sln = "./Microsoft.Maui.Graphics-net6.sln";
}
else
{
sln = "./Microsoft.Maui.Graphics.Mac-net6.slnf";
}
}
if (isCIBuild)
{
Information("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 });
}
}
// NOTE: These methods work as long as the "dotnet" target has already run
void RunMSBuildWithDotNet(
string sln,
Dictionary<string, string> properties = null,
string target = "Build",
bool warningsAsError = false,
bool restore = true,
string targetFramework = null)
{
var name = System.IO.Path.GetFileNameWithoutExtension(sln);
var binlog = string.IsNullOrEmpty(targetFramework) ?
$"\"{logDirectory}/{name}-{configuration}-{target}.binlog\"" :
$"\"{logDirectory}/{name}-{configuration}-{target}-{targetFramework}.binlog\"";
if(localDotnet)
SetDotNetEnvironmentVariables();
// If we're not on Windows, use ./bin/dotnet/dotnet
if (!IsRunningOnWindows() || target == "Run")
{
var msbuildSettings = new DotNetCoreMSBuildSettings()
.SetConfiguration(configuration)
.SetMaxCpuCount(0)
.WithTarget(target)
.EnableBinaryLogger(binlog);
if (warningsAsError)
{
msbuildSettings.TreatAllWarningsAs(MSBuildTreatAllWarningsAs.Error);
}
if (properties != null)
{
foreach (var property in properties)
{
msbuildSettings.WithProperty(property.Key, property.Value);
}
}
var dotnetBuildSettings = new DotNetCoreBuildSettings
{
MSBuildSettings = msbuildSettings,
};
dotnetBuildSettings.ArgumentCustomization = args =>
{
if (!restore)
args.Append("--no-restore");
if (!string.IsNullOrEmpty(targetFramework))
args.Append($"-f {targetFramework}");
return args;
};
DotNetCoreTool("pwsh", settings);
if (localDotnet)
dotnetBuildSettings.ToolPath = dotnetPath;
});
DotNetCoreBuild(sln, dotnetBuildSettings);
}
else
{
// Otherwise we need to run MSBuild for WinUI support
var msbuild = FindMSBuild();
Information("Using MSBuild: {0}", msbuild);
var msbuildSettings = new MSBuildSettings { ToolPath = msbuild }
.SetConfiguration(configuration)
.SetMaxCpuCount(0)
.WithTarget(target)
.EnableBinaryLogger(binlog);
if (warningsAsError)
{
msbuildSettings.WarningsAsError = true;
}
if (restore)
{
msbuildSettings.WithRestore();
}
if (!string.IsNullOrEmpty(targetFramework))
{
msbuildSettings.WithProperty("TargetFramework", targetFramework);
}
if (properties != null)
{
foreach (var property in properties)
{
msbuildSettings.WithProperty(property.Key, property.Value);
}
}
MSBuild(sln, msbuildSettings);
}
}
void RunTestWithLocalDotNet(string csproj)
{
var name = System.IO.Path.GetFileNameWithoutExtension(csproj);
var binlog = $"{logDirectory}/{name}-{configuration}.binlog";
var results = $"{name}-{configuration}.trx";
if(localDotnet)
SetDotNetEnvironmentVariables();
DotNetCoreTest(csproj,
new DotNetCoreTestSettings
{
Configuration = configuration,
ToolPath = dotnetPath,
NoBuild = true,
Logger = $"trx;LogFileName={results}",
ResultsDirectory = testResultsDirectory,
ArgumentCustomization = args => args.Append($"-bl:{binlog}")
});
}

87
eng/cake/helpers.cake Normal file
Просмотреть файл

@ -0,0 +1,87 @@
Task("Clean")
.Description("Deletes all the obj/bin directories")
.Does(() =>
{
List<string> foldersToClean = new List<string>();
foreach (var item in new [] {"obj", "bin"})
{
foreach(string f in System.IO.Directory.GetDirectories(".", item, SearchOption.AllDirectories))
{
var directorySeparatorChar = System.IO.Path.DirectorySeparatorChar;
if(f.StartsWith($".{directorySeparatorChar}bin") || f.StartsWith($".{directorySeparatorChar}tools"))
continue;
// this is here as a safety check
if(!f.StartsWith($".{directorySeparatorChar}src"))
continue;
CleanDirectories(f);
}
}
});
T GetBuildVariable<T>(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));
}
string GetAndroidSDKPath()
{
var ANDROID_SDK_ROOT = Argument("android", EnvironmentVariable("ANDROID_SDK_ROOT") ?? EnvironmentVariable("ANDROID_HOME"));
if (string.IsNullOrEmpty(ANDROID_SDK_ROOT)) {
throw new Exception("Environment variable 'ANDROID_SDK_ROOT' or 'ANDROID_HOME' must be set to the Android SDK root.");
}
return ANDROID_SDK_ROOT;
}
public void PrintEnvironmentVariables()
{
var envVars = EnvironmentVariables();
string path;
if (envVars.TryGetValue("PATH", out path))
{
Information("Path: {0}", path);
}
foreach(var envVar in envVars)
{
Information(
"Key: {0}\tValue: \"{1}\"",
envVar.Key,
envVar.Value
);
};
}
void SetDotNetEnvironmentVariables(string dotnetDir)
{
var dotnet = dotnetDir ?? MakeAbsolute(Directory("./bin/dotnet/")).ToString();
SetEnvironmentVariable("DOTNET_INSTALL_DIR", dotnet);
SetEnvironmentVariable("DOTNET_ROOT", dotnet);
SetEnvironmentVariable("DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR", dotnet);
SetEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0");
SetEnvironmentVariable("MSBuildEnableWorkloadResolver", "true");
SetEnvironmentVariable("PATH", dotnet, prepend: true);
}
void SetEnvironmentVariable(string name, string value, bool prepend = false)
{
var target = EnvironmentVariableTarget.Process;
if (prepend)
value = value + System.IO.Path.PathSeparator + EnvironmentVariable(name);
Environment.SetEnvironmentVariable(name, value, target);
Information("Setting environment variable: {0} = '{1}'", name, value);
}