Skip to content

Commit 552c36c

Browse files
authored
Add support for osx-arm64 (#756)
* Add a job to build macos-arm64 binaries * Put arm64 in a unique output folder * Add osx-arm64 runtime identifier * Update local building docs
1 parent a6b9f9c commit 552c36c

File tree

3 files changed

+55
-11
lines changed

3 files changed

+55
-11
lines changed

docs/building-from-source.md

+2-10
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ dotnet run --project src/Microsoft.Sbom.Tool generate -b <drop path> -bc <build
4949

5050
## Building on ARM based devices running OSX
5151

52-
The sbom-tool targets both .NET 6 and .NET 8 therefore it is possible to produce binaries for both. We have seen issues when attempting to run the tool using the .NET 6 binaries ([#223](https://github.com/microsoft/sbom-tool/issues/223)) so for these scenarios we recommend targeting .NET 8. You can do this by following these steps:
52+
The tool provides an osx-arm64 version of the tool. If you need to build one locally, you can build it as follows:
5353

5454
The following command will produce a dll that can be executed on ARM based devices running OSX and can be modified to suit your needs:
5555

5656
```
57-
dotnet publish src/Microsoft.Sbom.Tool/Microsoft.Sbom.Tool.csproj --configuration Release --output bin --runtime osx-arm64 -p:TargetFramework=net8.0 -p:SelfContained=true -p:OFFICIAL_BUILD=true -p:MinVerVersionOverride=1.8.0 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true -p:DebugType=None -p:DebugSymbols=false
57+
dotnet publish src/Microsoft.Sbom.Tool/Microsoft.Sbom.Tool.csproj --configuration Release --output bin --runtime osx-arm64 -p:TargetFramework=net8.0 -p:SelfContained=true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true -p:DebugType=None
5858
```
5959

6060
After running this command you can execute the tool like this:
@@ -63,14 +63,6 @@ After running this command you can execute the tool like this:
6363
./bin/Microsoft.Sbom.Tool generate -b ~/tmp/sbom-tool/ -bc ~/tmp/sbom-tool/ -pn TestProject -pv 1.2.3 -ps Microsoft
6464
```
6565

66-
## Using Dotnet Publish
67-
68-
Because of our multi-targeting, a target framework must be specified when using the dotnet publish command:
69-
70-
```
71-
dotnet publish -f net8.0
72-
```
73-
7466
## Building using Codespaces
7567

7668
After accessing [GitHub Codespaces](https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces/about-codespaces), select the `Code` button from the [repository homepage](https://github.com/microsoft/sbom-tool), then select `Open with Codespaces`. That's it! Users will then have a full developer environment that supports debugging, testing, auto complete, jump to definitions, and everything that one would expect.

pipelines/sbom-tool-main-build.yaml

+52
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ variables:
2121
ForceSigning: 'false'
2222
WindowsNetRuntime: 'win-x64'
2323
MacOSNetRuntime: 'osx-x64'
24+
MacOSArm64NetRuntime: 'osx-arm64'
2425
LinuxNetRuntime: 'linux-x64'
2526
BinaryNameWindows: 'sbom-tool-win-x64.exe'
2627
BinaryNameMacOS: 'sbom-tool-osx-x64'
28+
BinaryNameMacOSArm64: 'sbom-tool-osx-arm64'
2729
BinaryNameLinux: 'sbom-tool-linux-x64'
2830

2931
extends:
@@ -297,3 +299,53 @@ extends:
297299
Move-Item -Path $(Build.ArtifactStagingDirectory)/osx/$(BinaryNameMacOS) -Destination $(Build.ArtifactStagingDirectory)/bin/$(BinaryNameMacOS)
298300
Remove-Item $(Build.ArtifactStagingDirectory)/osx -Recurse
299301
displayName: 'Restructure Artifact'
302+
303+
- job: Job_4
304+
displayName: 'Build (macOS-arm64)'
305+
templateContext:
306+
outputs:
307+
- output: pipelineArtifact
308+
targetPath: $(Build.ArtifactStagingDirectory)
309+
artifactName: '$(OutputArtifactName)-macOS-arm64'
310+
pool:
311+
name: Azure Pipelines
312+
image: macos-latest
313+
os: macOS
314+
steps:
315+
- task: UseDotNet@2
316+
displayName: 'Use .NET Core'
317+
inputs:
318+
useGlobalJson: true
319+
320+
- task: DotNetCoreCLI@2
321+
displayName: 'Restore solution'
322+
inputs:
323+
command: restore
324+
feedsToUse: config
325+
nugetConfigPath: nuget.config
326+
verbosityRestore: Normal
327+
328+
- task: DotNetCoreCLI@2
329+
displayName: Build
330+
inputs:
331+
arguments: '-c $(BuildConfiguration)'
332+
333+
- task: DotNetCoreCLI@2
334+
displayName: 'Build self-contained binary'
335+
inputs:
336+
command: publish
337+
publishWebProjects: false
338+
projects: src/Microsoft.Sbom.Tool/Microsoft.Sbom.Tool.csproj
339+
arguments: '-c $(BuildConfiguration) --no-restore --output $(Build.ArtifactStagingDirectory)/osx-arm64 --self-contained --runtime $(MacOSArm64NetRuntime) -p:PublishSingleFile=true -p:DebugType=None -f net8.0'
340+
zipAfterPublish: false
341+
modifyOutputPath: false
342+
343+
- powershell: 'Rename-Item -Path $(Build.ArtifactStagingDirectory)\osx-arm64\Microsoft.Sbom.Tool -NewName $(BinaryNameMacOSArm64)'
344+
displayName: 'Rename binaries'
345+
346+
- powershell: |
347+
del $(Build.ArtifactStagingDirectory)/CodeSignSummary-*.md
348+
mkdir $(Build.ArtifactStagingDirectory)/bin
349+
Move-Item -Path $(Build.ArtifactStagingDirectory)/osx-arm64/$(BinaryNameMacOSArm64) -Destination $(Build.ArtifactStagingDirectory)/bin/$(BinaryNameMacOSArm64)
350+
Remove-Item $(Build.ArtifactStagingDirectory)/osx-arm64 -Recurse
351+
displayName: 'Restructure Artifact'

src/Microsoft.Sbom.Tool/Microsoft.Sbom.Tool.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<AssemblyName>Microsoft.Sbom.Tool</AssemblyName>
6-
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
6+
<RuntimeIdentifiers>win-x64;osx-x64;osx-arm64;linux-x64</RuntimeIdentifiers>
77
<IsPublishable>true</IsPublishable>
88
<GenerateRuntimeConfigDevFile>true</GenerateRuntimeConfigDevFile>
99
<Description>Highly scalable and enterprise ready tool to create SBOMs for any variety of artifacts.</Description>

0 commit comments

Comments
 (0)