-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creation of .NET executable file broken with .NET 5 SDK #148
Comments
Oh neat! Thanks for the report. |
Okay, after some further digging, it looks like building the actual .exe will be challenging, because it's not done by the compiler directly. However, I think an executable dll assembly can be emitted, but it needs one, and possibly two, things. First, it the rules need to not set the extension to Second, it may need an emitted "AssemblyAttributes.cs" source file to be generated that has the framework version attribute. This appears to be generated by Visual Studio under the
What actions need to happen to actually create the executable file (.exe) will need some further investigation. |
I'll attempt to generate a PR for at least the temporary (dll-only) solution ASAP. |
Cool, thanks! That sounds good. |
@j3parker The immediate "cannot execute an executable assembly at all" issue is now fixed with PR #145 (merged in bf24e58). I strongly suspect that you're on the right track as to what the VS-generated executable is actually doing. The .exe generated is not a raw .NET assembly. In the VS build process, there's a |
Ahh good pointer. That got me to https://github.com/dotnet/runtime/blob/master/src/installer/managed/Microsoft.NET.HostModel/AppHost/HostWriter.cs and yeah it looks something like that. It sounds like we probably want to mimic I think probably the app host output would be a separate build output, and we'd probably still need to do special assembly loading stuff to solve something like #9 (where we want to use the DLLs spread out across the disk in the way Bazel likes). |
When building an executable assembly (
csharp_binary
), the C# compiler has changed its behavior with the release of .NET 5.0. Previously, the C# compiler would simply create the executable assembly, with a.exe
extension, and it was possible to executedotnet <assembly name>.exe
and have the executable run. This is the pattern used by these C# Bazel rules. This is no longer the case with .NET 5.0.Now, the compiler emits two assemblies,
<assembly name>.dll
and<assembly name>.exe
with an<assembly name>.deps.json
file that references the dll (Note: I do not yet know if the json file is generated bycsc.exe
, or by MSBuild). With the binaries created by MSBuild/Visual Studio, it is possible to execute the created .dll usingdotnet <assembly name>.dll
, or to execute<assembly name>.exe
directly. Accordingly, the Bazel rules should ideally emit the same file list that the MSBuild task emits, but an acceptable solution would be to just emit the .dll that can be executed viadotnet <assembly name>.dll
.The text was updated successfully, but these errors were encountered: