-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test out cross compilation of dotnet app to executable
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: cross compile dotnet app | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
pull_request: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
build: | ||
runs-on: macos-14 | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
- uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: 7.x | ||
- name: build dotnet executables | ||
run: make build | ||
- name: size of executables | ||
run: make size | ||
- name: file info | ||
run: make file | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
path: bin/* | ||
|
||
test: | ||
defaults: | ||
run: | ||
shell: sh | ||
needs: [build] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: ["macos-14"] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Download all workflow run artifacts | ||
uses: actions/download-artifact@v3 | ||
- name: list bin | ||
run: ls bin/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
all: build | ||
|
||
APP_NAME = "hello_dotnet" | ||
|
||
RIDS = "linux-x64" "linux-arm64" "linux-musl-x64" "linux-musl-arm64" "osx-x64" "osx-arm64" "win-x64" "win-arm64" | ||
|
||
build: clean | ||
for rid in $(RIDS); do \ | ||
echo "Building for $$rid..."; \ | ||
dotnet publish -c Release -p:PublishSingleFile=true -p:SelfContained=true -p:PublishReadyToRun=true -p:PublishTrimmed=true -p:StaticLink=true -r $$rid -o bin/$(APP_NAME)-$$rid; \ | ||
done || true | ||
|
||
# the above true condition is a yak shave, | ||
# /usr/local/share/dotnet/sdk/7.0.409/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Publish.targets(111,5): | ||
# error NETSDK1098: Applications published to a single-file are required to use the application host. | ||
# You must either set PublishSingleFile to false or set UseAppHost to true. | ||
|
||
debug: clean | ||
@echo "Building in debug mode..." | ||
for rid in $(RIDS); do \ | ||
echo "Building for $$rid..."; \ | ||
dotnet publish -c Debug -p:PublishSingleFile=true -p:SelfContained=true -p:PublishReadyToRun=true-r $$rid -o bin/$(APP_NAME)-$$rid; \ | ||
done | ||
|
||
size: | ||
@echo "Size of the binaries:" | ||
for rid in $(RIDS); do \ | ||
echo "Size of bin/$(APP_NAME)-$$rid:"; \ | ||
ls -lh bin/$(APP_NAME)-$$rid/; \ | ||
done | ||
|
||
file: | ||
@echo "File type of the binaries:" | ||
for rid in $(RIDS); do \ | ||
echo "File type of bin/$(APP_NAME)-$$rid:"; \ | ||
file bin/$(APP_NAME)-$$rid/*; \ | ||
done | ||
|
||
clean: | ||
@echo "Cleaning..." | ||
@rm -rf bin | ||
@rm -rf obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters