[src] Build the .NET version of our product assemblies using a .NET 5 BCL. (#9637)

* [src] Build the .NET version of our product assemblies using a .NET 5 BCL.

We're not shipping the .NET product assemblies in any stable release, so we
can use a preview version of the .NET 5 BCL.

Also:

* Add all the nuget feeds we need to the top-level NuGet.config, even for .NET
  5/6, there shouldn't be any conflicts with stable feeds since we use exact
  version numbers.

* Generate a top-level global5.json which is copied to every directory that
  needs a .NET 5 global.json (overriding the .NET 3.1 global.json in the root
  directory).

* Use the expected dotnet binary during our local build.

* [tests] Fix the bgen tests to use .NET 5.

* [xharness] Set the current directory to the project directory when running .NET tests.

This way we end up using the dotnet version that's configured in global.json for the tests.
This commit is contained in:
Rolf Bjarne Kvinge 2020-09-21 13:22:44 +02:00 коммит произвёл GitHub
Родитель 569b484ba7
Коммит 39e3184f02
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 77 добавлений и 53 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -31,6 +31,7 @@ tests/bcl-test/mscorlib*.csproj
tests/bcl-test/SystemCoreXunit*.csproj
tests/bcl-test/SystemXunit.csproj
global.json
global5.json
.idea
device-tests-provisioning.csx
mono_crash.*.json

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

@ -433,9 +433,6 @@ endif
DOTNET_VERSION=3.1.100
DOTNET_URL=https://download.visualstudio.microsoft.com/download/pr/787e81f1-f0da-4e3b-a989-8a199132ed8c/61a8dba81fbf2b3d533562d7b96443ec/dotnet-sdk-3.1.100-osx-x64.pkg
DOTNET=/usr/local/share/dotnet/dotnet
DOTNET_BCL_REF_URL=https://www.nuget.org/api/v2/package/Microsoft.NETCore.App.Ref/3.1.0
DOTNET_BCL_REF_NAME=microsoft.netcore.app.ref.3.1.0.nupkg
DOTNET_BCL_DIR:=$(abspath $(TOP)/builds/downloads/$(basename $(DOTNET_BCL_REF_NAME)))/ref/netcoreapp3.1
DOTNET_DESTDIR ?= $(TOP)/_build
DOTNET_NUPKG_DIR ?= $(DOTNET_DESTDIR)/nupkgs
@ -454,6 +451,9 @@ DOTNET5=$(DOTNET)
else
DOTNET5=$(abspath $(TOP)/builds/downloads/dotnet/$(DOTNET5_VERSION))/dotnet
endif
DOTNET5_BCL_REF_URL=https://pkgs.dev.azure.com/dnceng/9ee6d478-d288-47f7-aacc-f6e6d082ae6d/_packaging/7d9f5c21-0d79-403f-bfe3-9a4506529760/nuget/v3/flat2/microsoft.netcore.app.ref/5.0.0-rc.1.20404.16/microsoft.netcore.app.ref.5.0.0-rc.1.20404.16.nupkg
DOTNET5_BCL_REF_NAME=microsoft.netcore.app.ref.5.0.0-rc.1.20404.16.nupkg
DOTNET5_BCL_DIR:=$(abspath $(TOP)/builds/downloads/$(basename $(DOTNET5_BCL_REF_NAME)))/ref/net5.0
DOTNET_PLATFORMS=
ifdef INCLUDE_IOS

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

@ -49,10 +49,19 @@ ifdef INCLUDE_IOS
@echo Validated file permissions for Xamarin.iOS.
endif
all-local:: global.json
all-local:: global.json global5.json
global.json: Make.config Makefile
$(Q) printf "{\n\t\"sdk\": {\n\t\t\"version\": \"$(DOTNET_VERSION)\"\n\t}\n}\n" > $@
# This tells NuGet to use the exact same dotnet version we've configured in Make.config
global5.json: $(TOP)/Make.config.inc Makefile $(TOP)/.git/HEAD $(TOP)/.git/index
$(Q_GEN) \
printf "{\n" > $@; \
printf "\t\"sdk\": { \"version\": \"$(DOTNET5_VERSION)\" },\n" >> $@; \
printf "\t\"msbuild-sdks\": {\n" >> $@; \
printf "\t\t\"Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk\": \"5.0.0-beta.20120.1\"\n" >> $@; \
printf "\t}\n}\n" >> $@
install-hook::
@$(MAKE) check-permissions
ifdef INCLUDE_IOS

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

@ -6,6 +6,8 @@
<packageSources>
<add key="Nuget Official" value ="https://www.nuget.org/api/v2/" />
<add key="Dotnet arcade" value ="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
</packageSources>
</configuration>

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

@ -15,14 +15,14 @@ download-mono: downloads/$(basename $(MONO_IOS_FILENAME)) downloads/$(basename $
downloads/$(basename $(MONO_IOS_FILENAME)): MONO_URL=$(MONO_IOS_URL)
downloads/$(basename $(MONO_MAC_FILENAME)): MONO_URL=$(MONO_MAC_URL)
downloads/$(DOTNET_BCL_REF_NAME): MONO_URL=$(DOTNET_BCL_REF_URL)
downloads/$(DOTNET5_BCL_REF_NAME): MONO_URL=$(DOTNET5_BCL_REF_URL)
include $(TOP)/mk/colors.mk
DOWNLOADS = \
downloads/$(MONO_IOS_FILENAME) \
downloads/$(MONO_MAC_FILENAME) \
downloads/$(DOTNET_BCL_REF_NAME) \
downloads/$(DOTNET5_BCL_REF_NAME) \
# This target downloads the mono archives, there's one for Xamarin.iOS and one for Xamarin.Mac.
# If doing many clean builds, it's possible to copy the downloaded zip file to ~/Library/Caches/xamarin-macios
@ -68,7 +68,7 @@ downloads/%: downloads/%.nupkg
$(Q) touch $@
DOTNET_DOWNLOADS = \
downloads/$(basename $(DOTNET_BCL_REF_NAME)) \
downloads/$(basename $(DOTNET5_BCL_REF_NAME)) \
dotnet: $(DOTNET_DOWNLOADS)
ifdef ENABLE_DOTNET

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

@ -140,13 +140,8 @@ all-local:: $(TARGETS) targets/Xamarin.Shared.Sdk.Versions.props
endif
# This tells NuGet to use the exact same dotnet version we've configured in Make.config
global.json: $(TOP)/Make.config.inc Makefile $(TOP)/.git/HEAD $(TOP)/.git/index
$(Q_GEN) \
printf "{\n" > $@; \
printf "\t\"sdk\": { \"version\": \"$(DOTNET5_VERSION)\" },\n" >> $@; \
printf "\t\"msbuild-sdks\": {\n" >> $@; \
printf "\t\t\"Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk\": \"5.0.0-beta.20120.1\"\n" >> $@; \
printf "\t}\n}\n" >> $@
global.json: $(TOP)/global5.json
$(CP) $< $@
clean-local::
$(Q) rm -Rf $(DOTNET_NUPKG_DIR) $(DOTNET_FEED_DIR)

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

@ -26,41 +26,41 @@ TVOS_DOTNET_BUILD_DIR=$(DOTNET_BUILD_DIR)/tvos
GENERATOR_FLAGS=-process-enums -core -nologo -nostdlib -noconfig -native-exception-marshalling --ns:ObjCRuntime
DOTNET_REFERENCES = \
/r:$(DOTNET_BCL_DIR)/System.Buffers.dll \
/r:$(DOTNET_BCL_DIR)/System.Collections.Concurrent.dll \
/r:$(DOTNET_BCL_DIR)/System.Collections.dll \
/r:$(DOTNET_BCL_DIR)/System.Collections.NonGeneric.dll \
/r:$(DOTNET_BCL_DIR)/System.Console.dll \
/r:$(DOTNET_BCL_DIR)/System.Diagnostics.Debug.dll \
/r:$(DOTNET_BCL_DIR)/System.Diagnostics.Tools.dll \
/r:$(DOTNET_BCL_DIR)/System.Drawing.Primitives.dll \
/r:$(DOTNET_BCL_DIR)/System.IO.Compression.dll \
/r:$(DOTNET_BCL_DIR)/System.IO.FileSystem.dll \
/r:$(DOTNET_BCL_DIR)/System.Linq.dll \
/r:$(DOTNET_BCL_DIR)/System.Memory.dll \
/r:$(DOTNET_BCL_DIR)/System.Net.Http.dll \
/r:$(DOTNET_BCL_DIR)/System.Net.NameResolution.dll \
/r:$(DOTNET_BCL_DIR)/System.Net.Primitives.dll \
/r:$(DOTNET_BCL_DIR)/System.Net.Requests.dll \
/r:$(DOTNET_BCL_DIR)/System.Net.Security.dll \
/r:$(DOTNET_BCL_DIR)/System.Net.ServicePoint.dll \
/r:$(DOTNET_BCL_DIR)/System.Net.Sockets.dll \
/r:$(DOTNET_BCL_DIR)/System.Resources.ResourceManager.dll \
/r:$(DOTNET_BCL_DIR)/System.Runtime.dll \
/r:$(DOTNET_BCL_DIR)/System.Runtime.Extensions.dll \
/r:$(DOTNET_BCL_DIR)/System.Runtime.InteropServices.dll \
/r:$(DOTNET_BCL_DIR)/System.Security.Cryptography.X509Certificates.dll \
/r:$(DOTNET_BCL_DIR)/System.Text.RegularExpressions.dll \
/r:$(DOTNET_BCL_DIR)/System.Threading.dll \
/r:$(DOTNET_BCL_DIR)/System.Threading.Tasks.dll \
/r:$(DOTNET_BCL_DIR)/System.Threading.Thread.dll \
/r:$(DOTNET_BCL_DIR)/System.Xml.dll \
/r:$(DOTNET_BCL_DIR)/System.Xml.ReaderWriter.dll \
/r:$(DOTNET5_BCL_DIR)/System.Buffers.dll \
/r:$(DOTNET5_BCL_DIR)/System.Collections.Concurrent.dll \
/r:$(DOTNET5_BCL_DIR)/System.Collections.dll \
/r:$(DOTNET5_BCL_DIR)/System.Collections.NonGeneric.dll \
/r:$(DOTNET5_BCL_DIR)/System.Console.dll \
/r:$(DOTNET5_BCL_DIR)/System.Diagnostics.Debug.dll \
/r:$(DOTNET5_BCL_DIR)/System.Diagnostics.Tools.dll \
/r:$(DOTNET5_BCL_DIR)/System.Drawing.Primitives.dll \
/r:$(DOTNET5_BCL_DIR)/System.IO.Compression.dll \
/r:$(DOTNET5_BCL_DIR)/System.IO.FileSystem.dll \
/r:$(DOTNET5_BCL_DIR)/System.Linq.dll \
/r:$(DOTNET5_BCL_DIR)/System.Memory.dll \
/r:$(DOTNET5_BCL_DIR)/System.Net.Http.dll \
/r:$(DOTNET5_BCL_DIR)/System.Net.NameResolution.dll \
/r:$(DOTNET5_BCL_DIR)/System.Net.Primitives.dll \
/r:$(DOTNET5_BCL_DIR)/System.Net.Requests.dll \
/r:$(DOTNET5_BCL_DIR)/System.Net.Security.dll \
/r:$(DOTNET5_BCL_DIR)/System.Net.ServicePoint.dll \
/r:$(DOTNET5_BCL_DIR)/System.Net.Sockets.dll \
/r:$(DOTNET5_BCL_DIR)/System.Resources.ResourceManager.dll \
/r:$(DOTNET5_BCL_DIR)/System.Runtime.dll \
/r:$(DOTNET5_BCL_DIR)/System.Runtime.Extensions.dll \
/r:$(DOTNET5_BCL_DIR)/System.Runtime.InteropServices.dll \
/r:$(DOTNET5_BCL_DIR)/System.Security.Cryptography.X509Certificates.dll \
/r:$(DOTNET5_BCL_DIR)/System.Text.RegularExpressions.dll \
/r:$(DOTNET5_BCL_DIR)/System.Threading.dll \
/r:$(DOTNET5_BCL_DIR)/System.Threading.Tasks.dll \
/r:$(DOTNET5_BCL_DIR)/System.Threading.Thread.dll \
/r:$(DOTNET5_BCL_DIR)/System.Xml.dll \
/r:$(DOTNET5_BCL_DIR)/System.Xml.ReaderWriter.dll \
DOTNET_FLAGS=/noconfig /nostdlib+ /deterministic /features:strict /nologo /target:library /debug /unsafe /define:NET /define:NET_TODO $(DOTNET_REFERENCES)
DOTNET_COMPILER=$(DOTNET_BUILD_DIR)/compiler
DOTNET_GENERATOR_FLAGS=$(GENERATOR_FLAGS) -compiler=$(abspath $(DOTNET_COMPILER)) --lib=$(DOTNET_BCL_DIR) -attributelib:$(DOTNET_BINDING_ATTRIBUTES) $(DOTNET_REFERENCES)
DOTNET_GENERATOR_FLAGS=$(GENERATOR_FLAGS) -compiler=$(abspath $(DOTNET_COMPILER)) --lib=$(DOTNET5_BCL_DIR) -attributelib:$(DOTNET_BINDING_ATTRIBUTES) $(DOTNET_REFERENCES)
DOTNET_GENERATOR=$(DOTNET_BUILD_DIR)/bgen/bgen
DOTNET_BINDING_ATTRIBUTES=$(DOTNET_BUILD_DIR)/Xamarin.Apple.BindingAttributes.dll
@ -1194,6 +1194,10 @@ $(DOTNET_COMPILER): Makefile $(TOP)/Make.config | $(DOTNET_BUILD_DIR)
$(Q) echo "exec $(SYSTEM_CSC) $(DOTNET_FLAGS) \"\$$@\"" >> $@
$(Q) chmod +x $@
# This tells NuGet to use the exact same dotnet version we've configured in Make.config
global.json: $(TOP)/global5.json
$(Q) $(CP) $< $@
install-local:: $(INSTALL_TARGETS)
all-local:: $(ALL_TARGETS)

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

@ -13,9 +13,12 @@ $(BUILD_DIR)/generator.csproj: generator.csproj | $(BUILD_DIR)
$(BUILD_DIR)/common/bgen.exe: $(generator_dependencies) Makefile.generator $(BUILD_DIR)/generator-frameworks.g.cs
$(Q_GEN) $(SYSTEM_MSBUILD) $(XBUILD_VERBOSITY) /p:Configuration=Debug generator.csproj /p:IntermediateOutputPath=$(BUILD_DIR)/IDE/obj/common/ /p:OutputPath=$(BUILD_DIR)/common
$(DOTNET_BUILD_DIR)/bgen/bgen: $(generator_dependencies) Makefile.generator $(BUILD_DIR)/generator-frameworks.g.cs | $(DOTNET_BUILD_DIR)/bgen
$(Q_DOTNET_BUILD) $(DOTNET) build $(XBUILD_VERBOSITY) /p:Configuration=Debug bgen/bgen.csproj /p:IntermediateOutputPath=$(abspath $(DOTNET_BUILD_DIR)/IDE/obj/common)/ /p:OutputPath=$(abspath $(DOTNET_BUILD_DIR)/IDE/bin/common)/
$(DOTNET_BUILD_DIR)/bgen/bgen: $(generator_dependencies) Makefile.generator $(BUILD_DIR)/generator-frameworks.g.cs global.json | $(DOTNET_BUILD_DIR)/bgen
$(Q_DOTNET_BUILD) $(DOTNET5) publish $(XBUILD_VERBOSITY) /p:Configuration=Debug bgen/bgen.csproj /p:IntermediateOutputPath=$(abspath $(DOTNET_BUILD_DIR)/IDE/obj/common)/ /p:OutputPath=$(abspath $(DOTNET_BUILD_DIR)/IDE/bin/common)/
$(Q) $(CP) $(DOTNET_BUILD_DIR)/IDE/bin/common/bgen* $(dir $@)
$(Q) printf 'exec $(DOTNET5) "$$(dirname "$$0")"/bgen.dll $$@\n' > $@
$(Q) chmod +x $@
$(DOTNET_DESTDIR)/%.Sdk/tools/lib/bgen/bgen: $(DOTNET_BUILD_DIR)/bgen/bgen | $(DOTNET_DESTDIR)/%.Sdk/tools/lib/bgen
$(Q) rm -f $(dir $@)/bgen*

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

@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFramework>net5.0</TargetFramework>
<OutputType>Exe</OutputType>
<DefineConstants>DEBUG;BGENERATOR;NET_4_0;NO_AUTHENTICODE;STATIC;NO_SYMBOL_WRITER</DefineConstants>
</PropertyGroup>

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

@ -4,4 +4,4 @@ pushd "$(dirname "$0")/.." > /dev/null
MONOTOUCH_PREFIX=$(pwd -P)
popd > /dev/null
exec "$MONOTOUCH_PREFIX/lib/bgen/bgen" "$@"
exec dotnet "$MONOTOUCH_PREFIX/lib/bgen/bgen.dll" "$@"

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

@ -1,3 +1,4 @@
NuGet.config
generated-projects
*index.html
*.log

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>bgen_tests</RootNamespace>
<IsPackable>false</IsPackable>

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

@ -7,7 +7,6 @@ include $(TOP)/Make.config
NuGet.config: $(TOP)/NuGet.config Makefile
$(Q) $(CP) $< $@.tmp
$(Q) nuget sources add -Name local-dotnet-feed -Source $(abspath $(DOTNET_FEED_DIR)) -ConfigFile $@.tmp
$(Q) nuget sources add -Name dotnet5 -Source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" -ConfigFile $@.tmp
$(Q) nuget config -Set globalPackagesFolder=$(abspath $(CURDIR)/packages) -Config $@.tmp
$(Q) nuget config -Set repositorypath=$(abspath $(CURDIR)/packages) -Config $@.tmp
$(Q) mv $@.tmp $@
@ -24,8 +23,16 @@ global.json: $(TOP)/Make.config.inc Makefile $(TOP)/.git/HEAD $(TOP)/.git/index
printf "\t\t\"Microsoft.macOS.Sdk\": \"$(MACOS_NUGET_VERSION_NO_METADATA)\"\n" >> $@; \
printf "\t}\n}\n" >> $@
../bgen/global.json: global.json
$(Q) $(CP) $< $@
../bgen/NuGet.config: NuGet.config
$(Q) $(CP) $< $@
TARGETS += \
NuGet.config \
global.json \
../bgen/NuGet.config \
../bgen/global.json \
all-local:: $(TARGETS)

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

@ -27,6 +27,8 @@ namespace Xharness.Jenkins.TestTasks {
"--logger:html;LogFileName=" + Path.GetFileName (html.FullPath)
};
WorkingDirectory = Path.GetDirectoryName (ProjectFile);
await ExecuteProcessAsync (Jenkins.Harness.GetDotNetExecutable (Path.GetDirectoryName (ProjectFile)), args);
}
}

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

@ -63,7 +63,7 @@ Xamarin.Mac.registrar.mobile.x86_64.m: $(TOP)/src/build/mac/mobile-64/Xamarin.Ma
$(Q) touch Xamarin.Mac.registrar.mobile.x86_64.m Xamarin.Mac.registrar.mobile.x86_64.h
Microsoft.macOS.registrar.x86_64.m: $(TOP)/src/build/dotnet/macos/64/Xamarin.Mac.dll $(LOCAL_MMP)
$(GENERATE_PART_REGISTRAR) --target-framework .NETCoreApp,Version=5.0,Profile=macos -a:$(DOTNET_BCL_DIR)/System.Runtime.dll
$(GENERATE_PART_REGISTRAR) --target-framework .NETCoreApp,Version=5.0,Profile=macos -a:$(DOTNET5_BCL_DIR)/System.Runtime.dll
$(Q) touch $@ $(basename $@).h
Xamarin.Mac.registrar.full.x86_64.m: $(TOP)/src/build/mac/full-64/Xamarin.Mac.dll $(LOCAL_MMP)

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

@ -218,7 +218,7 @@ define RunRegistrar
$$(Q) touch $$(basename $$@).m $$(basename $$@).h
.libs/Microsoft.$(9).registrar.$(10)%m .libs/Microsoft.$(9).registrar.$(10)%h: $(TOP)/src/build/dotnet/$(1)/$(3)/Xamarin.$(5).dll $(LOCAL_MTOUCH) | .libs
$$(Q_GEN) $$(LOCAL_MTOUCH_COMMAND) --xamarin-framework-directory=$$(IOS_DESTDIR)/$$(MONOTOUCH_PREFIX) $$(MTOUCH_VERBOSITY) --runregistrar:$$(abspath $$(basename $$@).m) --sdkroot $$(XCODE_DEVELOPER_ROOT) --sdk $(4) $$< --registrar:static --target-framework .NETCoreApp,Version=5.0,Profile=$(1) --abi $(2) -r:$(DOTNET_BCL_DIR)/System.Runtime.dll
$$(Q_GEN) $$(LOCAL_MTOUCH_COMMAND) --xamarin-framework-directory=$$(IOS_DESTDIR)/$$(MONOTOUCH_PREFIX) $$(MTOUCH_VERBOSITY) --runregistrar:$$(abspath $$(basename $$@).m) --sdkroot $$(XCODE_DEVELOPER_ROOT) --sdk $(4) $$< --registrar:static --target-framework .NETCoreApp,Version=5.0,Profile=$(1) --abi $(2) -r:$(DOTNET5_BCL_DIR)/System.Runtime.dll
$$(Q) touch $$(basename $$@).m $$(basename $$@).h
%.registrar.$(1).$(2).a: %.registrar.$(1).$(2).m %.registrar.$(1).$(2).h