Skip to content

Instantly share code, notes, and snippets.

@baronfel
Created September 20, 2023 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baronfel/12386b8961b0324b1ee8697d10554eee to your computer and use it in GitHub Desktop.
Save baronfel/12386b8961b0324b1ee8697d10554eee to your computer and use it in GitHub Desktop.
.NET CLI command for cross-platform AOT
# the nuget.config is needed to get nightly feeds, since the 'nightly' container is also using rc2 builds of sdk/runtime ahead of release
# the docker socket and docker binary are needed to light up the SDK tooling
# the nightly base image is needed because the -aot SDK images are only present there
# the explicit ContainerBaseImage is because SDK base image inference doesn't know about the 'nightly' feeds pattern
docker run --rm -it \
-v $(pwd):/source \
-v $(pwd)/../../nuget.config:/source/nuget.config \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /usr/bin/docker:/usr/bin/docker \
-w /source \
mcr.microsoft.com/dotnet/nightly/sdk:8.0-jammy-aot \
dotnet publish /t:PublishContainer /p:ContainerBaseImage=mcr.microsoft.com/dotnet/runtime-deps:8.0.0-rc.1 /p PublishAot=true -bl -r linux-x64
@lbussell
Copy link

Should /p:ContainerBaseImage=mcr.microsoft.com/dotnet/runtime-deps:8.0.0-rc.1
be mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-aot instead?

@baronfel
Copy link
Author

@lbussell that would definitely work but would represent a user choosing to use the chiseled version (probably through our 'ContainerFamily' property) - I was going for the 'first step' here of just getting the AOT'd app on the runtime. Then further enhancements would be using the chiseled base images, stripping symbols, etc - depending on how far the user wanted to go on the size vs capabilities scale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment