Enable mono packages (#33074)
authorJo Shields <directhex@apebox.org>
Tue, 3 Mar 2020 14:43:25 +0000 (09:43 -0500)
committerGitHub <noreply@github.com>
Tue, 3 Mar 2020 14:43:25 +0000 (09:43 -0500)
* Build Mono nupkgs

* Add Mono to runtime-official.yml

* Define isOfficialJob for Mono

* Try not nesting if statements, use and instead

* Publish Mono nupkgs

* Do intermediate upload, copied from CoreCLR

* Forcibly embed ELF buildid on Mono on Linux

This is not default in our local Clang builds on CentOS7, and
is rejected during publishing

* Version number fixups from CoreCLR

* Steal logic from Installer to force musl RID on musl

* Add an override so Windows RID used on Windows

eng/pipelines/mono/templates/build-job.yml
eng/pipelines/runtime-official.yml
src/mono/mono.proj
src/mono/netcore/nuget/Directory.Build.props

index a29c07e..34ce6bc 100644 (file)
@@ -10,6 +10,7 @@ parameters:
   pool: ''
   condition: true
   llvm: false
+  isOfficialBuild: false
   crossrootfsDir: ''
 
 ### Product build
@@ -50,7 +51,22 @@ jobs:
       value: ${{ parameters.osGroup }}
     - name: osSubgroup
       value: ${{ parameters.osSubgroup }}
-
+    - name: officialBuildIdArg
+      value: ''
+    # Strip symbols only on the release build
+    - ${{ if eq(parameters.buildConfig, 'Release') }}:
+      - name: stripSymbolsArg
+        value: '-stripsymbols'
+    - ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest')) }}:
+      - name: officialBuildIdArg
+        value: '/p:officialBuildId=$(Build.BuildNumber)'
+    - ${{ if and(eq(parameters.osSubgroup, '_musl'), eq(parameters.osGroup, 'Linux')) }}:
+      # Set output RID manually: musl isn't properly detected. Make sure to also convert linux to
+      # lowercase for RID format. (Detection normally converts, but we're preventing it.)
+      - name: OutputRidArg
+        value: /p:OutputRid=linux-musl-${{ parameters.archType }}
+      - name: _PortableBuild
+        value: true
     - ${{ parameters.variables }}
 
     steps:
@@ -86,6 +102,39 @@ jobs:
         artifactName: $(buildProductArtifactName)
         displayName: 'product build'
 
+    # Build packages
+    - ${{ if and(ne(parameters.llvm, true), ne(parameters.osGroup, 'Windows_NT')) }}:
+      - script: ./mono$(scriptExt) -configuration $(buildConfig) -arch $(archType) -ci $(officialBuildIdArg) /p:MonoEnableLLVM=${{ parameters.llvm }} -pack $(OutputRidArg)
+        displayName: Build nupkg
+    - ${{ if and(ne(parameters.llvm, true), eq(parameters.osGroup, 'Windows_NT')) }}:
+      - script: mono$(scriptExt) -configuration $(buildConfig) -arch $(archType) -ci $(officialBuildIdArg) /p:MonoEnableLLVM=${{ parameters.llvm }} -pack $(OutputRidArg)
+        displayName: Build nupkg
+
+    # Save packages using the prepare-signed-artifacts format.
+    - ${{ if eq(parameters.isOfficialBuild, true) }}:
+      - template: /eng/pipelines/common/upload-unsigned-artifacts-step.yml
+        parameters:
+          name: ${{ parameters.platform }}
+
+    # Publish official build
+    - ${{ if and(ne(parameters.llvm, true), eq(parameters.publishToBlobFeed, 'true')) }}:
+      - ${{ if ne(parameters.osGroup, 'Windows_NT') }}:
+        - script: $(Build.SourcesDirectory)/eng/common/build.sh --ci --restore --publish --configuration $(_BuildConfig) /p:DotNetPublishUsingPipelines=true /p:DotNetPublishToBlobFeed=true /p:DotNetPublishBlobFeedUrl=$(dotnetfeedUrl) /p:DotNetPublishBlobFeedKey=$(dotnetfeedPAT) /p:__BuildType=$(_BuildConfig) /p:__BuildArch=$(archType) /p:__BuildOS=$(osGroup) /p:OSIdentifier=$(osGroup)$(osSubgroup) /bl:"$(Build.SourcesDirectory)/artifacts/log/publish-pkgs.binlog" --projects $(Build.SourcesDirectory)/eng/empty.csproj
+          displayName: Publish packages to blob feed
+          env:
+            # TODO: remove NUGET_PACKAGES once https://github.com/dotnet/arcade/issues/1578 is fixed
+            NUGET_PACKAGES: $(Build.SourcesDirectory)/.packages
+            ${{ if eq(parameters.osGroup, 'FreeBSD') }}:
+              # Arcade uses this SDK instead of trying to restore one.
+              DotNetCoreSdkDir: /usr/local/dotnet
+      - ${{ if eq(parameters.osGroup, 'Windows_NT') }}:
+        # TODO: pass publish feed url and access token in from the internal pipeline
+        - powershell: eng\common\build.ps1 -ci -restore -publish -configuration $(_BuildConfig) /p:DotNetPublishUsingPipelines=true /p:DotNetPublishToBlobFeed=true /p:DotNetPublishBlobFeedUrl=$(dotnetfeedUrl) /p:DotNetPublishBlobFeedKey=$(dotnetfeedPAT) /p:__BuildType=$(_BuildConfig) /p:__BuildArch=$(archType) /p:__BuildOS=$(osGroup) /p:OSIdentifier=$(osGroup)$(osSubgroup) /bl:"$(Build.SourcesDirectory)\artifacts\log\publish-pkgs.binlog" -projects $(Build.SourcesDirectory)\eng\empty.csproj
+          displayName: Publish packages to blob feed
+          env:
+            # TODO: remove NUGET_PACKAGES once https://github.com/dotnet/arcade/issues/1578 is fixed
+            NUGET_PACKAGES: $(Build.SourcesDirectory)\.packages
+
     # Publish Logs
     - task: PublishPipelineArtifact@1
       displayName: Publish Logs
index 20ac28b..7619c2e 100644 (file)
@@ -61,6 +61,28 @@ stages:
         isOfficialBuild: ${{ variables.isOfficialBuild }}
 
   #
+  # Build Mono release
+  #
+  - template: /eng/pipelines/common/platform-matrix.yml
+    parameters:
+      jobTemplate: /eng/pipelines/mono/templates/build-job.yml
+      runtimeFlavor: mono
+      buildConfig: release
+      platforms:
+      - OSX_x64
+      - Linux_x64
+      - Linux_arm
+      - Linux_arm64
+      - Linux_musl_x64
+      # - Linux_musl_arm64
+      - Windows_NT_x64
+      # - Windows_NT_x86
+      # - Windows_NT_arm
+      # - Windows_NT_arm64
+      jobParameters:
+        isOfficialBuild: ${{ variables.isOfficialBuild }}
+
+  #
   # Build libraries using live CoreLib from CoreCLR
   #
   - template: /eng/pipelines/common/platform-matrix.yml
index c73e974..a0f3329 100644 (file)
@@ -54,6 +54,9 @@
         <_MonoConfigureParams>$(_MonoConfigureParams) AR=$(_MonoTuple)-ar</_MonoConfigureParams>
         <_MonoConfigureParams>$(_MonoConfigureParams) STRIP=$(_MonoTuple)-strip</_MonoConfigureParams>
     </PropertyGroup>
+    <PropertyGroup Condition="'$(TargetsLinux)' == true">
+        <_MonoExtraCFLAGS>$(_MonoExtraCFLAGS) -Wl,--build-id</_MonoExtraCFLAGS>
+    </PropertyGroup>
     <PropertyGroup>
         <_MonoConfigureParams Condition="'$(MonoEnableLLVM)' == 'true'">$(_MonoConfigureParams) --with-llvm=$(MonoLLVMDir) </_MonoConfigureParams>
         <_MonoConfigureParams>$(_MonoConfigureParams) --enable-maintainer-mode --enable-compile-warnings --with-core=only </_MonoConfigureParams>
index 662c5d5..9a0aea0 100644 (file)
@@ -15,6 +15,7 @@
     <!-- Distro rid is passed as runtimeos-arch-->
     <_parseDistroRid>$(__DistroRid)</_parseDistroRid>
     <_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(TargetsOSX)' == 'true'">osx.10.12-x64</_parseDistroRid>
+    <_parseDistroRid Condition="'$(_parseDistroRid)' == '' and '$(TargetsWindows)' == 'true'">win-x64</_parseDistroRid>
     <_distroRidIndex>$(_parseDistroRid.IndexOfAny("-"))</_distroRidIndex>
     <_archRidIndex>$([MSBuild]::Add($(_distroRidIndex), 1))</_archRidIndex>
     <OSRid Condition="'$(OSRid)' == '' and '$(_distroRidIndex)' != '-1'">$(_parseDistroRid.SubString(0, $(_distroRidIndex)))</OSRid>