Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
chucker authored May 24, 2021
1 parent ca4f7b4 commit f6d0e70
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# net6-mac-console-sample
A minimal example of using .NET 6 for an app that uses macOS native APIs

# Ingredients
## Build

* Start with a console template: `dotnet new console`
* Change the target framework to `net6.0-macos`, and the runtime identifier to `osx-x64`
* During previews, add a `NuGet.config` so you get packages such as `microsoft.macos.runtime.osx-x64`
* Add an Info.plist
Start with a console template: `dotnet new console`.

In the `csproj`,

* Change the target framework to `net6.0-macos`
* Specify the runtime identifier `osx-x64`
* Add `<SelfContained>true</SelfContained>`

During previews, add a `NuGet.config` so you get packages such as `microsoft.macos.runtime.osx-x64`

Add an `Info.plist`.

Your project now references Cocoa. You can do `using Foundation` for low-level types like `NSString`, and `using AppKit` for GUI types like `NSTextView`.

# Status
## Run

As of preview 3, you must run the binary inside the bundle for the libraries to be found correctly, e.g.:

bin/Debug/net6.0-macos/osx-x64/net6-console-mac-sample.app/Contents/MacOS/net6-console-mac-sample

This will not work:

As of preview 3, while the references do get pulled in, calling any Foundation or AppKit code at runtime seems to fail.
dotnet bin/Debug/net6.0-macos/osx-x64/net6-console-mac-sample.dll

0 comments on commit f6d0e70

Please sign in to comment.