Skip to content

Commit

Permalink
Add check for .NET 5 SDK, update NativeLibrary sample instructions (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Jan 29, 2021
1 parent d47918d commit 0a644c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
14 changes: 0 additions & 14 deletions samples/HelloWorld/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,3 @@ where `<Configuration>` is your project configuration (such as Debug or Release)
Once completed, you can find the native executable in the root folder of your project under `/bin/<Configuration>/net5.0/<RID>/publish/`. Navigate to `/bin/<Configuration>/net5.0/<RID>/publish/` in your project folder and run the produced native executable.

Feel free to modify the sample application and experiment. However, keep in mind some functionality might not yet be supported in CoreRT. Let us know on the [Issues page](https://github.com/dotnet/runtimelab/issues).

## Know Issues

It's recommended to target `net5.0` or newer when building CoreRT apps. However, if for some reason you have to stay with older .NET Core version like `netcoreapp2.1`, you might get the following error:

```log
Project is targeting runtime 'win-x64' but did not resolve any runtime-specific packages for the 'Microsoft.NETCore.App' package. This runtime may not be supported by .NET Core.
```

In such case, you need to add following setting to your project file:

```xml
<EnsureNETCoreAppRuntime>false</EnsureNETCoreAppRuntime>
```
6 changes: 3 additions & 3 deletions samples/NativeLibrary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ Create a .NET Core class library project using `dotnet new classlib -o NativeLib
## Building static libraries

```bash
> dotnet publish /p:NativeLib=Static -r <RID> -c <Configuration>
> dotnet publish /p:NativeLib=Static /p:SelfContained=true -r <RID> -c <Configuration>
```

where `<Configuration>` is your project configuration (such as Debug or Release) and `<RID>` is the runtime identifier (one of win-x64, linux-x64, osx-x64). For example, if you want to publish a release configuration of your library for a 64-bit version of Windows the command would look like:

```bash
> dotnet publish /p:NativeLib=Static -r win-x64 -c release
> dotnet publish /p:NativeLib=Static /p:SelfContained=true -r win-x64 -c release
```

The above command will drop a static library (Windows `.lib`, OSX/Linux `.a`) in `./bin/[configuration]/netstandard2.0/[RID]/publish/` folder and will have the same name as the folder in which your source file is present.

## Building shared libraries

```bash
> dotnet publish /p:NativeLib=Shared -r <RID> -c <Configuration>
> dotnet publish /p:NativeLib=Shared /p:SelfContained=true -r <RID> -c <Configuration>
```

The above command will drop a shared library (Windows `.dll`, OSX `.dylib`, Linux `.so`) in `./bin/[configuration]/netstandard2.0/[RID]/publish/` folder and will have the same name as the folder in which your source file is present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<Target Name="_ComputeAssembliesToCompileToNative" DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)">

<!-- Fail with descriptive error message for common mistake. -->
<Error Condition="$([MSBuild]::VersionLessThan('$(NETCoreSdkVersion)', '5.0.0'))" Text=".NET SDK 5+ is required for native compilation." />
<Error Condition="'$(RuntimeIdentifier)' == ''" Text="RuntimeIdentifier is required for native compilation. Try running dotnet publish with the -r option value specified." />
<Error Condition="'$(GeneratePackageOnBuild)' == 'true'" Text="GeneratePackageOnBuild is not supported for native compilation." />
<Error Condition="'$(OutputType)' != 'Library' and '$(NativeLib)' != ''" Text="NativeLib requires OutputType=Library." />
Expand Down

0 comments on commit 0a644c7

Please sign in to comment.