Skip to content

Commit

Permalink
Publish Signed Standalone Executables from archetype-tool-dotnet (#…
Browse files Browse the repository at this point in the history
…4895)

* update organization to split apart the binaries and packages artifacts
* updating calls to net-release-to-feed@azure-sdk-build-tools to take advantage of new binary signing capabilities
* update test-proxy to .NET 6 only
* update test-proxy publishing to omit test package
* add osx-arm64 to test-proxy standalone executable matrix
  • Loading branch information
scbedd authored Dec 12, 2022
1 parent c7f236a commit 7dbcb86
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 17 deletions.
17 changes: 14 additions & 3 deletions eng/pipelines/templates/stages/archetype-sdk-tool-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ parameters:
- name: StandaloneExeMatrix
type: object
default: []
- name: ReleaseBinaries
type: boolean
default: false

variables:
- template: ../variables/globals.yml
Expand Down Expand Up @@ -66,7 +69,7 @@ stages:
inputs:
version: '${{ coalesce( parameters.DotNetCoreVersion, variables.DotNetCoreVersion) }}'

- script: 'dotnet pack /p:ArtifactsPackagesDir=$(Build.ArtifactStagingDirectory) $(Warn) -c Release'
- script: 'dotnet pack /p:ArtifactsPackagesDir=$(Build.ArtifactStagingDirectory)/packages $(Warn) -c Release'
displayName: 'Build and Package'
workingDirectory: '${{ coalesce(parameters.PackageDirectory, parameters.ToolDirectory) }}'
env:
Expand All @@ -80,11 +83,17 @@ stages:
BuildMatrix: ${{ parameters.StandaloneExeMatrix }}
TargetDirectory: '${{ coalesce(parameters.PackageDirectory, parameters.ToolDirectory) }}'

- publish: $(Build.ArtifactStagingDirectory)
displayName: Publish package to run artifacts
- publish: $(Build.ArtifactStagingDirectory)/packages
displayName: Publish to packages artifact
artifact: packages
condition: succeededOrFailed()

- ${{ if gt(length(parameters.StandaloneExeMatrix), 0) }}:
- publish: $(Build.ArtifactStagingDirectory)/binaries
displayName: Publish executables to binaries artifact
artifact: binaries
condition: succeededOrFailed()

- job: Test

steps:
Expand Down Expand Up @@ -124,6 +133,8 @@ stages:
parameters:
# Publish to https://dev.azure.com/azure-sdk/public/_packaging?_a=feed&feed=azure-sdk-for-net
DevOpsFeedId: '29ec6040-b234-4e31-b139-33dc4287b756/fa8c16a3-dbe0-4de2-a297-03065ec1ba3f'
ExeMatrix: ${{ parameters.StandaloneExeMatrix }}
ShouldPublishExecutables: ${{ parameters.ReleaseBinaries }}

- ${{if and(not(eq(length(parameters.DockerDeployments), 0)), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}:
- stage: PublishDockerImages
Expand Down
18 changes: 11 additions & 7 deletions eng/pipelines/templates/steps/produce-net-standalone-packs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,29 @@ parameters:
# framework: net6.0

steps:
- pwsh: |
mkdir -p "$(Build.ArtifactStagingDirectory)/binaries"
displayName: Create destination directory
- ${{ each target in parameters.BuildMatrix }}:
- pwsh: |
$destinationPathSegment = "$(Build.ArtifactStagingDirectory)/$((Split-Path -Leaf "${{ parameters.TargetDirectory }}"))-standalone-${{ target.rid }}"
$destinationPathSegment = "$(Build.ArtifactStagingDirectory)/binaries/$((Split-Path -Leaf "${{ parameters.TargetDirectory }}"))-standalone-${{ target.rid }}"
$sourcePath = "${{ parameters.TargetDirectory }}/${{ target.rid }}"
Write-Host "dotnet publish -f ${{ target.framework }} -c Release -r ${{ target.rid }} --self-contained --output ${{ parameters.TargetDirectory }}/${{ target.rid }}"
dotnet publish -f ${{ target.framework }} -c Release -r ${{ target.rid }} --self-contained --output ${{ parameters.TargetDirectory }}/${{ target.rid }}
Write-Host "dotnet publish -f ${{ target.framework }} -c Release -r ${{ target.rid }} --self-contained -p:PublishSingleFile=true --output ${{ parameters.TargetDirectory }}/${{ target.rid }}"
dotnet publish -f ${{ target.framework }} -c Release -r ${{ target.rid }} --self-contained -p:PublishSingleFile=true --output ${{ parameters.TargetDirectory }}/${{ target.rid }}
if ($LASTEXITCODE -ne 0) {
Write-Error "dotnet publish failed with exit code $LASTEXITCODE."
exit $LASTEXITCODE
}
# windows? produce a zip, otherwise tar.gz
if ("${{ target.rid }}".StartsWith("win")){
Compress-Archive -Path "$($sourcePath)/*" -DestinationPath "$($destinationPathSegment).zip"
# produce a tar.gz only for linux
if ("${{ target.rid }}".Contains("linux")){
tar -cvzf "$($destinationPathSegment).tar.gz" "$sourcePath"
}
else {
tar -cvzf "$($destinationPathSegment).tar.gz" "$sourcePath"
Compress-Archive -Path "$($sourcePath)/*" -DestinationPath "$($destinationPathSegment).zip"
}
# clean up the uncompressed artifact directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6.0;net5.0</TargetFrameworks>
<TargetFrameworks>net6.0</TargetFrameworks>
<NoWarn>$(NoWarn);1591;AZC0001;AZC0012;CA1724;CA1801;CA1812;CA1822;SA1028</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -129,8 +129,10 @@ public string GetClassDocComment(Type type, XmlDocument docCommentXml)
// for this to work you need to have generatexmldoc activated and the generated comment xml MUST be alongside the assembly
public XmlDocument GetDocCommentXML()
{
var location = Assembly.Location;
using (var xmlReader = new StreamReader(Path.ChangeExtension(location, ".xml")))
var location = System.AppContext.BaseDirectory;

var name = Assembly.GetName().Name;
using (var xmlReader = new StreamReader(Path.Join(location, $"{name}.xml")))
{
XmlDocument result = new XmlDocument();
result.Load(xmlReader);
Expand Down
8 changes: 5 additions & 3 deletions tools/test-proxy/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ extends:
dockerRepo: 'engsys/test-proxy'
stableTags:
- 'latest'
ReleaseBinaries: true
StandaloneExeMatrix:
- rid: osx-x64
framework: net6.0
- rid: osx-arm64
framework: net6.0
- rid: win-x64
framework: net6.0
- rid: linux-x64
framework: net6.0
- rid: linux-arm64
framework: net6.0
- rid: osx-x64
framework: net6.0

0 comments on commit 7dbcb86

Please sign in to comment.