Brightspace / rules_csharp

Bazel rules for C#
Apache License 2.0
8 stars 5 forks source link

Add rule to create self-contained binaries for .NET Core #72

Open j3parker opened 4 years ago

j3parker commented 4 years ago

csharp_binary outputs IL files ("DLLs", but we currently give them a .exe extension anyway) but people will probably want the ability to create self-contained executable files.

With the usual SDK, you use dotnet publish --self-contained (see the docs).

I don't think this should be the default, because it would be simpler to keep everything in DLLs within the build graph (e.g. so you can add the output of csharp_binary to the deps of another rule.. a common use case being tests). I think we should have a specific rule for "packaging" a binary up. These rules wouldn't emit CSharpAssembly_* providers.

We need to investigate how this stuff works more. We don't have access to dotnet publish directly because we don't have the SDK. The SDKs are framework-specific, and right now we are manually using the runtime + the compiler as our toolchain (rather than having one toolchain per (platform, framework) pair).

jrbeverly commented 4 years ago

As of #97, we now have access to the full SDK. So for this task we now have access to dotnet publish directly.

For publishing up a self-contained binary I suspect we would have to generate a csproj file (similar to ResX). This would also likely be the case for #30.

There is discussion of this nature for dotnet pack about needing to generate a stub csproj file.