Merge remote-tracking branch 'origin/main' into bump-main-in-net8.0-2023-03-14

This commit is contained in:
Rolf Bjarne Kvinge 2023-03-23 08:36:21 +01:00
Родитель 32bab2476a e86c77a773
Коммит 4131267879
30 изменённых файлов: 543 добавлений и 107 удалений

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

@ -12,15 +12,31 @@ CURL = curl --fail --location --connect-timeout 15 $(if $(V),--verbose,--silent)
# --retry-all-errors: ignore the definition of insanity and retry even for errors that seem like you'd get the same result (such as 404). This isn't the real purpose, because this will also retry errors that will get a different result (such as connection failures / resets), which apparently --retry doesn't cover.
CURL_RETRY = $(CURL) --retry 20 --retry-delay 2 --retry-all-errors
DOTNET_TFM=net8.0
DOTNET_MAJOR_VERSION:=$(firstword $(subst ., ,$(subst net,,$(DOTNET_TFM))))
# calculate commit distance and store it in a file so that we don't have to re-calculate it every time make is executed.
# Support for hardcoding a commit distance start offset.
NUGET_VERSION_COMMIT_DISTANCE_START=0
NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=0
#
# The default is to add X000, where X is the major .NET version: we need to
# publish different versions of our NuGets for different .NET version
# (example: we need to publish one NuGet with support for Xcode 14.3 for .NET
# 6, and another one for .NET 7) - and these need to have different versions,
# and ordered correctly (the .NET 7 version must have a higher version than
# the .NET 6 version), and ideally it would be possible to just look at the
# version to see which .NET version it's targeting. Adding X000 to the commit
# distance accomplishes all these goals (as long as the commit distance itself
# doesn't need more than 3 digits).
NUGET_VERSION_COMMIT_DISTANCE_START=$(DOTNET_MAJOR_VERSION)000
NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=$(DOTNET_MAJOR_VERSION)000
-include $(TOP)/Make.config.inc
$(TOP)/Make.config.inc: $(TOP)/Make.config $(TOP)/mk/mono.mk
$(Q) cd $(TOP) && ALL_DOTNET_PLATFORMS="$(ALL_DOTNET_PLATFORMS)" ./create-make-config.sh
$(Q) cd $(TOP) && \
ALL_DOTNET_PLATFORMS="$(ALL_DOTNET_PLATFORMS)" \
NUGET_VERSION_COMMIT_DISTANCE_START=$(NUGET_VERSION_COMMIT_DISTANCE_START) \
NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=$(NUGET_VERSION_STABLE_COMMIT_DISTANCE_START) \
./create-make-config.sh
include $(TOP)/Make.versions
@ -607,7 +623,7 @@ else
DOTNET_BCL_VERSION=$(BUNDLED_NETCORE_PLATFORMS_PACKAGE_VERSION)
endif
DOTNET_TFM=net8.0
DOTNET_VERSION_BAND=$(firstword $(subst -, ,$(DOTNET_VERSION)))
DOTNET_VERSION_PRERELEASE_COMPONENT=$(subst $(DOTNET_VERSION_BAND),,$(DOTNET_VERSION))
DOTNET_INSTALL_NAME=dotnet-sdk-$(DOTNET_VERSION)
@ -637,7 +653,7 @@ EMSCRIPTEN_MANIFEST_VERSION_BAND=8.0.100-preview.2
# This is the manifest version band we use for our .Manifest-$(VERSION_BAND) packages.
# It should typically be $(DOTNET_MANIFEST_VERSION_BAND_WITH_PRERELEASE_COMPONENT), unless we decide to hardcode it to something else
MACIOS_MANIFEST_VERSION_BAND=$(DOTNET_MANIFEST_VERSION_BAND_WITH_PRERELEASE_COMPONENT)
MACIOS_MANIFEST_VERSION_BAND=$(MONO_TOOLCHAIN_MANIFEST_VERSION_BAND)
# Set this to 1 if the Microsoft.NETCore.App.Ref dependency in eng/Version.Details.xml does *not* specify a CoherentParentDependency on Microsoft.Dotnet.Sdk.Internal.
TRACKING_DOTNET_RUNTIME_SEPARATELY=

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

@ -10,12 +10,11 @@
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-emsdk -->
<add key="darc-pub-dotnet-emsdk-3d7178d" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-3d7178d8/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-emsdk -->
<!-- Begin: Package sources from dotnet-aspnetcore -->
<!-- End: Package sources from dotnet-aspnetcore -->
<!-- Begin: Package sources from dotnet-runtime -->
<add key="darc-pub-dotnet-runtime-1377e5e" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-1377e5e2/nuget/v3/index.json" />
<add key="darc-pub-dotnet-runtime-1e9466d" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-1e9466d9/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-runtime -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" protocolVersion="3" />

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

@ -11,10 +11,6 @@ rm -f "$OUTPUT_FILE" "$OUTPUT"
LANG=C
export LANG
# Support for hardcoding a commit distance start offset.
NUGET_VERSION_COMMIT_DISTANCE_START=0
NUGET_VERSION_STABLE_COMMIT_DISTANCE_START=0
# Compute commit distances
printf "IOS_COMMIT_DISTANCE:=$(git log $(git blame -- ./Make.versions HEAD | grep IOS_PACKAGE_VERSION= | sed 's/ .*//' )..HEAD --oneline | wc -l | sed 's/ //g')\n" >> "$OUTPUT_FILE"
printf "MAC_COMMIT_DISTANCE:=$(git log $(git blame -- ./Make.versions HEAD | grep MAC_PACKAGE_VERSION= | sed 's/ .*//' )..HEAD --oneline | wc -l | sed 's/ //g')\n" >> "$OUTPUT_FILE"

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

@ -89,12 +89,6 @@ using (TextWriter writer = new StreamWriter (outputPath)) {
var version = entry.Item2;
writer.WriteLine ($" <WorkloadPackages Include=\"$(NuGetPackagePath)\\Microsoft.NET.Sdk.{platform}.Manifest*.nupkg\" Version=\"{version}\" SupportsMachineArch=\"true\" />");
}
foreach (var entry in platforms) {
var platform = entry.Item1;
writer.WriteLine ($" <MultiTargetPackNames Include=\"Microsoft.{platform}.Sdk\" />");
if (windowsPlatforms.Contains (platform))
writer.WriteLine ($" <MultiTargetPackNames Include=\"Microsoft.{platform}.Windows.Sdk\" />");
}
writer.WriteLine (" </ItemGroup>");
writer.WriteLine ("</Project>");
}

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

@ -51,6 +51,10 @@
<Uri>https://github.com/xamarin/xamarin-macios</Uri>
<Sha>76c2f4bb2207459fa4bf8885b9ed81136e2fe0ab</Sha>
</Dependency>
<Dependency Name="Microsoft.NET.Workload.Emscripten.net7.Manifest-7.0.100" Version="7.0.4" CoherentParentDependency="Microsoft.NETCore.App.Ref">
<Uri>https://github.com/dotnet/emsdk</Uri>
<Sha>ba16583f6b055e5a0623d817a48f1f2f15629e6b</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="6.0.0-beta.21212.6">

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

@ -1,21 +0,0 @@
using Xamarin.Messaging.Build.Client;
namespace Xamarin.MacDev.Tasks {
public class CodesignVerify : CodesignVerifyTaskBase {
public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
return base.Execute ();
}
public override void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
base.Cancel ();
}
}
}

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

@ -4,17 +4,20 @@ using System.IO;
using Microsoft.Build.Framework;
using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;
using Xamarin.Utils;
#nullable enable
namespace Xamarin.MacDev.Tasks {
public abstract class CodesignVerifyTaskBase : XamarinToolTask {
public class CodesignVerify : XamarinToolTask {
#region Inputs
[Required]
public string CodesignAllocate { get; set; }
public string CodesignAllocate { get; set; } = string.Empty;
[Required]
public string Resource { get; set; }
public string Resource { get; set; } = string.Empty;
#endregion
@ -43,9 +46,9 @@ namespace Xamarin.MacDev.Tasks {
case ApplePlatform.iOS:
case ApplePlatform.TVOS:
case ApplePlatform.WatchOS:
case ApplePlatform.MacCatalyst:
args.AddQuoted ("-R=anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.1] exists and (certificate leaf[field.1.2.840.113635.100.6.1.2] exists or certificate leaf[field.1.2.840.113635.100.6.1.4] exists)");
break;
case ApplePlatform.MacCatalyst:
case ApplePlatform.MacOSX:
args.Add ("--deep");
break;
@ -66,11 +69,22 @@ namespace Xamarin.MacDev.Tasks {
public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
EnvironmentVariables = new string [] {
"CODESIGN_ALLOCATE=" + CodesignAllocate
};
return base.Execute ();
}
public override void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
base.Cancel ();
}
}
}

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

@ -1,28 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.Build.Framework;
using Xamarin.Messaging.Build.Client;
namespace Xamarin.MacDev.Tasks {
public class GetFiles : GetFilesTaskBase, ITaskCallback, ICancelableTask {
public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
return base.Execute ();
}
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
public bool ShouldCopyToBuildServer (ITaskItem item) => false;
public bool ShouldCreateOutputFile (ITaskItem item) => false;
public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}

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

@ -1,29 +1,36 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Xamarin.MacDev.Tasks;
using Xamarin.Localization.MSBuild;
using Xamarin.Messaging.Build.Client;
#nullable enable
namespace Xamarin.MacDev.Tasks {
public abstract class GetFilesTaskBase : XamarinTask {
public abstract class GetFiles : XamarinTask, ITaskCallback, ICancelableTask {
[Required]
public string Path { get; set; }
public string Path { get; set; } = string.Empty;
public string Pattern { get; set; }
public string Pattern { get; set; } = string.Empty;
public string Option { get; set; }
public string Option { get; set; } = string.Empty;
public string Exclude { get; set; }
public string Exclude { get; set; } = string.Empty;
[Output]
public ITaskItem [] Files { get; set; }
public ITaskItem [] Files { get; set; } = Array.Empty<ITaskItem> ();
public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
var path = Path.Replace ('\\', '/').TrimEnd ('/');
var exclude = new HashSet<string> ();
var items = new List<ITaskItem> ();
@ -66,5 +73,17 @@ namespace Xamarin.MacDev.Tasks {
return !Log.HasLoggedErrors;
}
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
public bool ShouldCopyToBuildServer (ITaskItem item) => false;
public bool ShouldCreateOutputFile (ITaskItem item) => false;
public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (BuildEngine4).Wait ();
}
}
}

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

@ -1959,7 +1959,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
-->
<Target
Name="_CodesignVerify"
Condition="'$(_CodesignAppBundleCondition)' == 'true' And '$(_RequireCodeSigning)' == 'true'"
Condition="'$(_CodesignAppBundleCondition)' == 'true' And '$(_RequireCodeSigning)' == 'true' And '$(DisableCodesignVerification)' != 'true'"
DependsOnTargets="_CodesignAppBundle"
>
<CodesignVerify

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

@ -103,27 +103,34 @@ namespace CoreGraphics {
#if NET
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
extern static unsafe IntPtr CGEventTapCreateForPSN (IntPtr processSerialNumer, CGEventTapLocation location, CGEventTapPlacement place, CGEventTapOptions options, CGEventMask mask, delegate* unmanaged<IntPtr, CGEventType, IntPtr, IntPtr, IntPtr> cback, IntPtr data);
extern static unsafe IntPtr CGEventTapCreateForPSN (IntPtr processSerialNumer, CGEventTapPlacement place, CGEventTapOptions options, CGEventMask mask, delegate* unmanaged<IntPtr, CGEventType, IntPtr, IntPtr, IntPtr> cback, IntPtr data);
#else
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
extern static IntPtr CGEventTapCreateForPSN (IntPtr processSerialNumer, CGEventTapLocation location, CGEventTapPlacement place, CGEventTapOptions options, CGEventMask mask, CGEventTapCallback cback, IntPtr data);
extern static IntPtr CGEventTapCreateForPSN (IntPtr processSerialNumer, CGEventTapPlacement place, CGEventTapOptions options, CGEventMask mask, CGEventTapCallback cback, IntPtr data);
#endif
[Obsolete ("The location parameter is not used. Consider using the overload without the location parameter.", false)]
[System.ComponentModel.EditorBrowsable (System.ComponentModel.EditorBrowsableState.Never)]
public static CFMachPort? CreateTap (IntPtr processSerialNumber, CGEventTapLocation location, CGEventTapPlacement place, CGEventTapOptions options, CGEventMask mask, CGEventTapCallback cback, IntPtr data)
{
#if NET
IntPtr r;
return CreateTap (processSerialNumber, place, options, mask, cback, data);
}
public static CFMachPort? CreateTap (IntPtr processSerialNumber, CGEventTapPlacement place, CGEventTapOptions options, CGEventMask mask, CGEventTapCallback cback, IntPtr data)
{
unsafe {
var psnPtr = new IntPtr (&processSerialNumber);
#if NET
var tapData = new TapData (cback, data);
var gch = GCHandle.Alloc (tapData);
r = CGEventTapCreateForPSN (processSerialNumber, location, place, options, mask, &TapCallback, GCHandle.ToIntPtr (gch));
}
var r = CGEventTapCreateForPSN (psnPtr, place, options, mask, &TapCallback, GCHandle.ToIntPtr (gch));
#else
var r = CGEventTapCreateForPSN (processSerialNumber, location, place, options, mask, cback, data);
var r = CGEventTapCreateForPSN (psnPtr, place, options, mask, cback, data);
#endif
if (r == IntPtr.Zero)
return null;
return new CFMachPort (r, true);
if (r == IntPtr.Zero)
return null;
return new CFMachPort (r, true);
}
}
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]

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

@ -1352,6 +1352,7 @@ define DotNetProjectFiles
$(DOTNET_BUILD_DIR)/projects/$(1)/$(1).csproj: dotnet.tmpl.csproj Makefile $$(wildcard $(CURDIR)/*.sources)
@mkdir -p $$(dir $$@)
@sed \
-e 's*%DOTNET_TFM%*$(DOTNET_TFM)*' \
-e 's*%PLATFORM%*$(1)*' \
-e 's*<!--%FILES%-->*$$(foreach file,$$($(2)_DOTNET_SOURCES),<Compile Include="../../../../$$(file)" Link="sources/$$(file)" />)*' \
-e 's*<!--%APIS%-->*$$(foreach file,$$($(2)_DOTNET_APIS),<None Include="../../../../$$(file)" Link="apis/$$(file)" />)*' \

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

@ -923,7 +923,7 @@ public partial class Generator : IMemberGatherer {
var nullable = TypeManager.GetUnderlyingNullableType (et);
if (nullable != null) {
return $"converted_{safe_name}";
} else if (et.IsValueType)
} else if (et.IsValueType) {
if (usingBlittableNativeTypes) {
if (et == TypeManager.System_Boolean) {
if (pi.IsOut)
@ -935,6 +935,7 @@ public partial class Generator : IMemberGatherer {
convs!.Append ($"{safe_name} = default ({blittableType});");
return $"({blittableType}*) global::System.Runtime.CompilerServices.Unsafe.AsPointer<{blittableType}> (ref {safe_name})";
}
}
return (pi.IsOut ? "out " : "ref ") + safe_name;
}
@ -1695,8 +1696,7 @@ public partial class Generator : IMemberGatherer {
#endif
print ("internal static unsafe {0} Invoke ({1}) {{", ti.ReturnType, ti.Parameters);
indent++;
print ("var descriptor = (BlockLiteral *) block;");
print ("var del = ({0}) (descriptor->Target);", ti.UserDelegate);
print ("var del = BlockLiteral.GetTarget<{0}> (block);", ti.UserDelegate);
bool is_void = ti.ReturnType == "void";
// FIXME: right now we only support 'null' when the delegate does not return a value
// otherwise we will need to know the default value to be returned (likely uncommon)

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

@ -3,10 +3,10 @@
<!-- This is a project file to load in the IDE to get code completion, etc. It's not used for building the product assemblies, that happens in the makefile -->
<PropertyGroup>
<_TargetPlatform>%PLATFORM%</_TargetPlatform>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>%DOTNET_TFM%</TargetFramework>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier> <!-- this line shouldn't be necessary, but VSMac on one of my machines won't load the project otherwise -->
<OutputType>Library</OutputType>
<AssemblyName>Xamarin.iOS</AssemblyName>
<AssemblyName>Microsoft.%PLATFORM%</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\..\product.snk</AssemblyOriginatorKeyFile>
<LangVersion>latest</LangVersion>

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

@ -320,21 +320,44 @@ function download_xcode_platforms ()
return
fi
TVOS_SIMULATOR_VERSION=$(/usr/libexec/PlistBuddy -c 'Print :ProductBuildVersion' "$XCODE_DEVELOPER_ROOT"/Platforms/AppleTVSimulator.platform/version.plist)
WATCHOS_SIMULATOR_VERSION=$(/usr/libexec/PlistBuddy -c 'Print :ProductBuildVersion' "$XCODE_DEVELOPER_ROOT"/Platforms/WatchSimulator.platform/version.plist)
local SIMULATOR_RUNTIMES
SIMULATOR_RUNTIMES=$("$XCODE_DEVELOPER_ROOT"/usr/bin/simctl runtime list)
if test -d "/Library/Developer/CoreSimulator/Volumes/tvOS_$TVOS_SIMULATOR_VERSION/Library/Developer/CoreSimulator/Profiles/Runtimes/tvOS $TVOS_VERSION.simruntime"; then
if test -d "/Library/Developer/CoreSimulator/Volumes/watchOS_$WATCHOS_SIMULATOR_VERSION/Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS $WATCHOS_VERSION.simruntime"; then
log "All the additional platforms have already been downloaded for this version of Xcode ($XCODE_VERSION)"
return
fi
TVOS_SIMULATOR_RUNTIME=$(echo "$SIMULATOR_RUNTIMES" | grep "^tvOS $TVOS_VERSION .*Ready" || true)
WATCHOS_SIMULATOR_RUNTIME=$(echo "$SIMULATOR_RUNTIMES" | grep "^watchOS $WATCHOS_VERSION .*Ready" || true)
MUST_INSTALL_RUNTIMES=
if test -z "$TVOS_SIMULATOR_RUNTIME"; then
MUST_INSTALL_RUNTIMES=1
fi
if ! test -z "$PROVISION_XCODE"; then
fail "Xcode has additional platforms that must be downloaded. Execute './system-dependencies.sh --provision-xcode' to execute those tasks."
if test -z "$WATCHOS_SIMULATOR_RUNTIME"; then
MUST_INSTALL_RUNTIMES=1
fi
if test -z "$MUST_INSTALL_RUNTIMES"; then
log "All the additional platforms have already been downloaded for this version of Xcode ($XCODE_VERSION)"
log " $TVOS_SIMULATOR_RUNTIME"
log " $WATCHOS_SIMULATOR_RUNTIME"
return
fi
if test -z "$PROVISION_XCODE"; then
fail "Xcode has additional platforms that must be downloaded. Execute './system-dependencies.sh --provision-xcode' to execute those tasks (or alternatively ${COLOR_MAGENTA}export IGNORE_XCODE=1${COLOR_RED} to skip this check)"
echo " ${COLOR_RED}Installed simulator runtimes:"
# shellcheck disable=SC2001
echo "$SIMULATOR_RUNTIMES" | sed 's/^/ /'
echo " Missing simulator runtimes:"
if test -z "$TVOS_SIMULATOR_RUNTIME"; then
fail " tvOS $TVOS_VERSION"
fi
if test -z "$WATCHOS_SIMULATOR_RUNTIME"; then
fail " watchOS $WATCHOS_VERSION"
fi
echo -n "${COLOR_CLEAR}"
return
fi
log "Xcode has additional platforms that must be downloaded ($MUST_INSTALL_RUNTIMES), so installing those."
log "Executing '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -downloadAllPlatforms'"
if ! "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -downloadAllPlatforms; then
"$XCODE_DEVELOPER_ROOT/usr/bin/simctl" runtime list -v

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

@ -18,6 +18,14 @@ namespace Cecil.Tests {
// This test verifies that we don't have any obsolete API in .NET that we don't expect to be there
// in particular that we don't start out with obsolete APIs from the very beginning (such API should have been removed).
// Any obsoleted API after the first stable .NET release should likely be skipped (until XAMCORE_5_0)
//
// If you have obsoleted a member and you're here wondering
// what you should do, you should add
// [EditorBrowsable (EditorBrowsableState.Never)]
// to the member in addition to the Obsolete. This will
// hide the member from intellisense but still allow it
// to compile (with errors/warnings).
//
[TestCaseSource (typeof (Helper), nameof (Helper.NetPlatformImplementationAssemblyDefinitions))] // call this method with every .net6 library
public void GetAllObsoletedThings (AssemblyInfo info)
{

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

@ -0,0 +1,12 @@
#nullable enable
namespace Xamarin.Tests {
[Category ("Windows")]
public class WindowsTest : TestBaseClass {
[Test]
public void OnlyOnWindows ()
{
Assert.True (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform (System.Runtime.InteropServices.OSPlatform.Windows), "On Windows");
}
}
}

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

@ -0,0 +1,168 @@
<!--
This is a heavily modified (simplified) copy of https://github.com/dotnet/maui/blob/47f8d3ba07661801094578f2d842426ba8a1fed9/src/DotNet/DotNet.csproj
-->
<Project Sdk="Microsoft.Build.NoTargets/3.3.0">
<PropertyGroup>
<RootSourceDirectory>$(MSBuildThisFileDirectory)\..\..\..\</RootSourceDirectory>
<DotNetOutputPath>$(MSBuildThisFileDirectory)bin\</DotNetOutputPath>
<DotNetTempDirectory>$(DotNetOutputPath)temp/</DotNetTempDirectory>
<DotNetDirectory>$(DotNetOutputPath)dotnet\</DotNetDirectory>
<DotNetToolPath>$(DotNetDirectory)dotnet</DotNetToolPath>
<DotNetPacksDirectory>$(DotNetDirectory)packs\</DotNetPacksDirectory>
<MacIosRootDirectory>$(RootSourceDirectory)</MacIosRootDirectory>
<PackageOutputPath>$(RootSourceDirectory)..\artifacts\</PackageOutputPath>
<RollbackFile>$(PackageOutputPath)WorkloadRollback\WorkloadRollback.json</RollbackFile>
<RollbackSource>$(PackageOutputPath)dotnet-signed</RollbackSource>
</PropertyGroup>
<Target Name="GetNuGetSources">
<GetNuGetSourcesTask RootSourceDirectory="$(RootSourceDirectory)">
<Output TaskParameter="NuGetSourceLines" ItemName="NuGetSourceLines" />
</GetNuGetSourcesTask>
<PropertyGroup>
<NuGetSourceList>--source @(NuGetSourceLines,' --source ')</NuGetSourceList>
</PropertyGroup>
</Target>
<UsingTask TaskName="GetNuGetSourcesTask"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<RootSourceDirectory ParameterType="System.String" />
<NuGetSourceLines ParameterType="System.String[]" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Using Namespace="System.Linq" />
<Code Type="Fragment" Language="cs">
<![CDATA[
// This is only in C#, because the equivalent MSBuild XML would not be pretty.
var path = Path.Combine (RootSourceDirectory, "NuGet.config");
var contents = File.ReadAllLines (path);
var sourceLines = contents
.Where (v => v.Contains ("https://pkgs.dev.azure.com"))
.Select (v => v.Substring (v.IndexOf ("value=\"") + "value=\"".Length))
.Select (v => v.Substring (0, v.IndexOf ("\"")))
.ToArray ();
NuGetSourceLines = sourceLines;
]]>
</Code>
</Task>
</UsingTask>
<Import Project="$(RootSourceDirectory)/eng/Versions.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<IsPackable>false</IsPackable>
<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>$(DotNetInstallCommand) -AzureFeed $(DotNetFeedUrl)</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>bash '$(DotNetInstallScriptPath)' --version $(MicrosoftDotnetSdkInternalPackageVersion) --install-dir '$(DotNetDirectory)' --verbose</DotNetInstallCommand>
<DotNetInstallCommand>$(DotNetInstallCommand) --azure-feed $(DotNetFeedUrl)</DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup>
<_ProvisionDependsOn>
_DownloadDotNetInstallScript;
_InstallDotNet;
_InstallWorkloadPacks;
</_ProvisionDependsOn>
</PropertyGroup>
<!-- 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="GetNuGetSources">
<Error
Condition=" '$(MSBuildRuntimeType)' != 'Core' "
Text="You should only run this target with 'dotnet build'."
/>
<PropertyGroup>
<_InstallTempDirectory>$(DotNetTempDirectory)install/</_InstallTempDirectory>
</PropertyGroup>
<!-- Run 'dotnet workload install' for the current running 'dotnet' install -->
<ItemGroup>
<_WorkloadSource Include="$(PackageOutputPath)" />
</ItemGroup>
<Copy SourceFiles="$(MacIosRootDirectory)NuGet.config" DestinationFolder="$(DotNetTempDirectory)" />
<Exec Command="&quot;$(DotNetToolPath)&quot; workload install ios tvos maccatalyst macos --verbosity diag --temp-dir &quot;$(DotNetTempDirectory)&quot; --configfile &quot;$(DotNetTempDirectory)NuGet.config&quot; --from-rollback-file &quot;$(RollbackFile)&quot; --source $(RollbackSource) --skip-sign-check $(NuGetSourceList)" WorkingDirectory="$(MacIosRootDirectory)" />
</Target>
<PropertyGroup>
<!-- These files should invalidate ./bin/dotnet completely -->
<_Inputs>
$(MSBuildThisFile);
$(RootSourceDirectory)/eng/Versions.props;
</_Inputs>
</PropertyGroup>
<Target Name="_DownloadDotNetInstallScript"
Inputs="$(_Inputs)"
Outputs="$(DotNetInstallScriptPath)">
<DownloadFile
SourceUrl="$(DotNetInstallScriptUrl)"
DestinationFolder="$(DotNetOutputPath)"
DestinationFileName="$(DotNetInstallScriptName)"
/>
</Target>
<Target Name="_InstallDotNet"
Inputs="$(_Inputs)"
Outputs="$(DotNetDirectory).stamp">
<RemoveDir Directories="$(DotNetDirectory)" />
<Exec Command="$(DotNetInstallCommand)" />
<Touch Files="$(DotNetDirectory).stamp" AlwaysCreate="true" />
<!-- This is used by iOS pair to mac because pair to mac can't
determine the version of preview versions. -->
<WriteLinesToFile
File="$(DotNetDirectory)dotnet-sdk-version.txt"
Lines="$(MicrosoftDotnetSdkInternalPackageVersion)"
Condition="$([MSBuild]::IsOSPlatform('windows'))"
Overwrite="true" />
</Target>
<ItemGroup>
<!-- Ids for 'dotnet workload install' -->
<_WorkloadIds Include="maccatalyst" />
<_WorkloadIds Include="macos" />
<_WorkloadIds Include="ios" />
<_WorkloadIds Include="tvos" />
</ItemGroup>
<Target Name="_InstallWorkloadPacks"
Inputs="$(_Inputs)"
Outputs="$(DotNetPacksDirectory).stamp">
<Exec
Command="&quot;$(DotNetToolPath)&quot; workload install %(_WorkloadIds.Identity) --skip-manifest-update --verbosity diag --temp-dir &quot;$(DotNetTempDirectory)&quot; --configfile &quot;$(MacIosRootDirectory)NuGet.config&quot;"
WorkingDirectory="$(MSBuildThisFileDirectory)"
EnvironmentVariables="DOTNET_MULTILEVEL_LOOKUP=0"
/>
<Touch Files="$(DotNetPacksDirectory).stamp" AlwaysCreate="true" />
</Target>
</Project>

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

@ -0,0 +1,47 @@
using System;
using Foundation;
#if MONOMAC
using AppKit;
#else
using UIKit;
#endif
using CoreGraphics;
using NUnit.Framework;
namespace MonoTouchFixtures.CoreGraphics {
[TestFixture]
[Preserve (AllMembers = true)]
public class CGEventTests {
#if MONOMAC
bool tapCalled = false;
IntPtr callBack (IntPtr tapProxyEvent, CGEventType eventType,
IntPtr eventRef, IntPtr userInfo)
{
tapCalled = true;
return eventRef;
}
[Test]
public void CreateTap ()
{
tapCalled = false;
var psn = (IntPtr) 2; // kCurrentProcess
var tapPort = CGEvent.CreateTap (CGEventTapLocation.AnnotatedSession, CGEventTapPlacement.HeadInsert, CGEventTapOptions.Default, CGEventMask.KeyDown, callBack, IntPtr.Zero);
Assert.IsNull (tapPort, "magically created tap port when not root");
Assert.IsFalse (tapCalled, "tap was mistakenly called.");
}
[Test]
public void CreateTapPSN ()
{
tapCalled = false;
var psn = (IntPtr) 2; // kCurrentProcess
var tapPort = CGEvent.CreateTap (psn, CGEventTapPlacement.HeadInsert, CGEventTapOptions.Default, CGEventMask.KeyDown, callBack, IntPtr.Zero);
Assert.IsNull (tapPort, "magically created tap port with OSN when not root");
Assert.IsFalse (tapCalled, "tap was mistakenly called.");
}
#endif
}
}

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

@ -1,4 +1,5 @@
#if !__WATCHOS__
using System;
using System.Threading;
using Foundation;
@ -37,6 +38,7 @@ namespace MonoTouchFixtures.Network {
[OneTimeSetUp]
public void Init ()
{
Exception ex = null;
TestRuntime.AssertXcodeVersion (11, 0);
// we want to use a single connection, since it is expensive
connectedEvent = new AutoResetEvent (false);
@ -45,7 +47,13 @@ namespace MonoTouchFixtures.Network {
using (var endpoint = NWEndpoint.Create (host, "80")) {
connection = new NWConnection (endpoint, parameters);
connection.SetQueue (DispatchQueue.DefaultGlobalQueue); // important, else we will get blocked
connection.SetStateChangeHandler (ConnectionStateHandler);
connection.SetStateChangeHandler ((NWConnectionState state, NWError error) => {
try {
ConnectionStateHandler (state, error);
} catch (Exception e) {
ex = e;
}
});
connection.Start ();
Assert.True (connectedEvent.WaitOne (20000), "Connection timed out.");
stack = parameters.ProtocolStack;
@ -60,6 +68,7 @@ namespace MonoTouchFixtures.Network {
}
}
}
Assert.IsNull (ex, "Exception");
}
[OneTimeTearDown]

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

@ -2562,7 +2562,7 @@ namespace MonoTouchFixtures.ObjCRuntime {
[DllImport ("/usr/lib/libobjc.dylib")]
static extern IntPtr class_getInstanceMethod (IntPtr cls, IntPtr sel);
#if !MONOMAC // Registrar_OutExportDerivedClass is from fsharp tests
#if !MONOMAC || NET // Registrar_OutExportDerivedClass is from fsharp tests
[Test]
public void OutOverriddenWithoutOutAttribute ()
{

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

@ -226,6 +226,7 @@ namespace Xharness.Jenkins {
TestProject = buildDotNetTestsProject,
Platform = TestPlatform.All,
TestName = "DotNet tests",
Filter = "Category!=Windows",
Timeout = TimeSpan.FromMinutes (360),
Ignored = !TestSelection.IsEnabled (TestLabel.DotnetTest),
};

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

@ -6,6 +6,7 @@ using Microsoft.DotNet.XHarness.iOS.Shared.Logging;
namespace Xharness.Jenkins.TestTasks {
class DotNetTestTask : RunTestTask {
public string Filter { get; set; } = string.Empty;
public DotNetTestTask (Jenkins jenkins, MSBuildTask build_task, IMlaunchProcessManager processManager)
: base (jenkins, build_task, processManager)
{
@ -27,6 +28,11 @@ namespace Xharness.Jenkins.TestTasks {
"--logger:html;LogFileName=" + Path.GetFileName (html.FullPath)
};
if (!string.IsNullOrEmpty (Filter)) {
args.Add ("--filter");
args.Add (Filter);
}
WorkingDirectory = Path.GetDirectoryName (ProjectFile);
await ExecuteProcessAsync (Jenkins.Harness.GetDotNetExecutable (Path.GetDirectoryName (ProjectFile)), args);

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

@ -124,7 +124,8 @@ for oldXcode in "${oldXcodes[@]}"; do
fi
done
DIR="$(dirname "${BASH_SOURCE[0]}")"
"$DIR"/clean-simulator-runtime.sh
# Print disk status after cleaning
df -h

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

@ -0,0 +1,37 @@
#!/bin/bash -eux
# find if there are any duplicated simulator runtimes for a given platform
set -o pipefail
IFS=$'\n\t'
xcrun simctl runtime list -j > simruntime.json
cat simruntime.json
grep -e '"identifier" : ' -e '"runtimeIdentifier" : ' simruntime.json | tr '\n' ' ' | sed -e 's/,//g' -e 's/"//g' -e 's/runtimeIdentifier : //g' -e $'s/identifier : /@/g' | tr '@' '\n' | awk NF | sed 's/^[[:blank:]]*//' > simruntime-lines.txt
cat simruntime-lines.txt
sed -e 's/.*com.apple/com.apple/g' simruntime-lines.txt > simruntime-runtimes.txt
cat simruntime-runtimes.txt
sort simruntime-runtimes.txt | uniq -c | sort -n | sed 's/^[[:blank:]]*//' > simruntime-runtimes-by-count.txt
cat simruntime-runtimes-by-count.txt
grep -v '^1 ' simruntime-runtimes-by-count.txt | sed 's/^[0-9 ]*//' > simruntime-duplicated-runtimes.txt
cat simruntime-duplicated-runtimes.txt
while IFS= read -r simruntime
do
echo "Duplicated: $simruntime"
grep "$simruntime" simruntime-lines.txt | sed 's/ .*//' | while IFS= read -r id
do
echo " sudo xcrun simctl runtime delete $id"
if ! sudo xcrun simctl runtime delete "$id"; then
echo " failed to delete runtime $id"
else
echo " deleted runtime $id"
fi
done
done < simruntime-duplicated-runtimes.txt
xcrun simctl runtime list -v

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

@ -1,11 +1,25 @@
#!/bin/bash -eux
# If BUILD_SOURCESDIRECTORY is not set, it's likely we're executing locally.
# In which case we can figure out where we are from the current git checkout
# (and also set BUILD_SOURCESDIRECTORY accordingly, since the rest of the
# script needs it).
if test -z "${BUILD_SOURCESDIRECTORY:-}"; then
BUILD_SOURCESDIRECTORY="$(git rev-parse --show-toplevel)/.."
fi
# Don't assume we're in the right directory (makes it easier to run the script
# locally).
cd "$BUILD_SOURCESDIRECTORY/xamarin-macios"
WORKLOAD_DST="$BUILD_SOURCESDIRECTORY/WorkloadRollback.json"
var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable VARIABLE=DOTNET_PLATFORMS)
DOTNET_PLATFORMS=${var#*=}
echo "Dotnet platforms are '$DOTNET_PLATFORMS'"
var=$(make -C "$BUILD_SOURCESDIRECTORY/xamarin-macios/tools/devops" print-variable VARIABLE=MACIOS_MANIFEST_VERSION_BAND)
MACIOS_MANIFEST_VERSION_BAND=${var#*=}
echo "{" > "$WORKLOAD_DST"
for platform in $DOTNET_PLATFORMS; do
CURRENT_UPPER=$(echo "$platform" | tr "[:lower:]" "[:upper:]")
@ -15,7 +29,7 @@ for platform in $DOTNET_PLATFORMS; do
NUGET_VERSION_FULL=${var#*=}
NUGET_VERSION_FULL=$(echo "$NUGET_VERSION_FULL" | cut -d "+" -f1)
echo "\"microsoft.net.sdk.$CURRENT_LOWER\": \"$NUGET_VERSION_FULL\"," >> "$WORKLOAD_DST"
echo "\"microsoft.net.sdk.$CURRENT_LOWER\": \"$NUGET_VERSION_FULL/$MACIOS_MANIFEST_VERSION_BAND\"," >> "$WORKLOAD_DST"
done
# Remove the trailing comma from the last entry, because json :/

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

@ -85,6 +85,7 @@ steps:
$platformUpper = $platform.ToUpperInvariant()
$version = $versionData."microsoft.net.sdk.$platformLower"
if (![string]::IsNullOrEmpty($version)) {
$version = $version.Substring(0, $version.IndexOf('/'))
Write-Host "Platform: $platform has version $version"
Write-Host "##vso[task.setvariable variable=$($platformUpper)_WORKLOAD_VERSION;]$version"
} else {

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

@ -27,6 +27,113 @@ steps:
gci env: | format-table -autosize -wrap
displayName: 'Dump Environment'
- task: DownloadPipelineArtifact@2
displayName: Download artifacts
inputs:
allowFailedBuilds: true
path: $(Build.SourcesDirectory)/artifacts
- pwsh: |
try {
Write-Host "Looking in '$(Build.SourcesDirectory)\artifacts"
Get-ChildItem "$(Build.SourcesDirectory)\artifacts" -Recurse
} catch {
Write-Host "Exception occured: $_"
}
displayName: 'List downloaded artifacts'
continueOnError: true
- task: UseDotNet@2
inputs:
version: 7.0.102
- pwsh: |
& dotnet --version
& dotnet --info
& dotnet workload list
displayName: 'Show .NET info'
continueOnError: true
# This task fixes errors such as these:
# error MSB4242: SDK Resolver Failure: "The SDK resolver "NuGetSdkResolver" failed while attempting to resolve the SDK "Microsoft.Build.NoTargets/3.3.0". Exception: "NuGet.Packaging.Core.PackagingException: Unable to find fallback package folder 'D:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages'.
- pwsh: |
try {
New-Item -Path "D:\Program Files (x86)\Microsoft SDKs\" -Name "NuGetPackages" -ItemType "directory"
} catch {
Write-Host "Exception occured: $_"
}
try {
New-Item -Path "D:\Program Files (x86)\Microsoft SDKs\" -Name "Shared" -ItemType "directory"
} catch {
Write-Host "Exception occured: $_"
}
try {
New-Item -Path "D:\Program Files (x86)\Microsoft SDKs\Shared\" -Name "NuGetPackages" -ItemType "directory"
} catch {
Write-Host "Exception occured: $_"
}
try {
New-Item -Path "D:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages" -Name "NuGetPackages" -ItemType "directory"
} catch {
Write-Host "Exception occured: $_"
}
displayName: 'Create directories for NuGet'
continueOnError: true
- pwsh: |
& dotnet build "$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/InstallDotNet.csproj" `
--verbosity quiet `
"-bl:$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/install.binlog" `
-p:DisableImplicitNuGetFallbackFolder=true
displayName: 'Install custom .NET'
continueOnError: true
- pwsh: |
$Env:DOTNET = "$(Build.SourcesDirectory)\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe"
& dotnet build "$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/InstallDotNet.csproj" `
--verbosity quiet `
"-bl:$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/install-workloads.binlog" `
-p:DisableImplicitNuGetFallbackFolder=true `
-t:Install
displayName: 'Install workloads'
continueOnError: true
# get and expand the needed libs for monotouch
- task: DownloadPipelineArtifact@2
displayName: Download test libraries dependencies
inputs:
patterns: '**/package-test-libraries.zip'
allowFailedBuilds: true
path: $(Build.SourcesDirectory)/artifacts/tmp
# this step replaces the test-libraries dir
- pwsh: |
$zip = "$(Build.SourcesDirectory)/artifacts/tmp/package-test-libraries/package-test-libraries.zip"
$target = "$(Build.SourcesDirectory)/xamarin-macios/tests/test-libraries"
Expand-Archive -Force $zip -DestinationPath $target
Get-ChildItem "$target" -Recurse
workingDirectory: $(Build.SourcesDirectory)/xamarin-macios/tests
displayName: Expand test libraries.
timeoutInMinutes: 10
- pwsh: |
& $(Build.SourcesDirectory)\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe `
nuget push `
"$(Build.SourcesDirectory)\xamarin-macios\tests\test-libraries\nugets\FrameworksInRuntimesNativeDirectory\bin\Debug\Xamarin.Tests.FrameworksInRuntimesNativeDirectory.1.0.0.nupkg" `
--source "$(Build.SourcesDirectory)\xamarin-macios\tests\.nuget\packages"
displayName: 'Build dependencies for .NET tests'
continueOnError: true
- pwsh: |
$Env:DOTNET = "$(Build.SourcesDirectory)\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe"
& $(Build.SourcesDirectory)\xamarin-macios\tests\dotnet\Windows\bin\dotnet\dotnet.exe `
test `
"$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/UnitTests/DotNetUnitTests.csproj" `
--filter Category=Windows `
--verbosity quiet `
"-bl:$(Build.SourcesDirectory)/xamarin-macios/tests/dotnet/Windows/run-dotnet-tests.binlog"
displayName: 'Run .NET tests'
- pwsh: |
Write-Host "Run windows tests."
Write-Host "Mac agent to be used:"

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

@ -37,6 +37,7 @@ stages:
displayName: ${{ parameters.displayName }}
dependsOn:
- build_packages
- sign_notarize_dotnet
condition: and(succeeded(), eq(dependencies.build_packages.outputs['configure.decisions.RUN_WINDOWS_TESTS'], 'true'))
jobs:

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

@ -16,7 +16,7 @@ DOTNET_DIRECTORIES += \
# dotnet-linker.csproj.inc contains the dotnet_linker_dependencies variable used to determine if mtouch needs to be rebuilt or not.
dotnet-linker.csproj.inc: export BUILD_EXECUTABLE=$(DOTNET) build
dotnet-linker.csproj.inc: export BUILD_VERBOSITY=$(DOTNET_BUILD_VERBOSITY)
dotnet-linker.csproj.inc:
dotnet-linker.csproj.inc: dotnet-linker.csproj
-include dotnet-linker.csproj.inc
$(BUILD_DIR)/dotnet-linker%dll $(BUILD_DIR)/dotnet-linker%pdb: Makefile $(dotnet_linker_dependencies)